Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    I've been dealing with this for about 2 days now. I think I'm just
    too close to the problem.

    I often recieve delimited text files from various source and have
    to read them into Access. Since the files are sometimes quite
    large and have upwards of 200 columns, I wrote a program to
    build a text file to document the name (if any), the true type of
    the variable, the true length of the variable and if the variable
    can be considered a categorical variable. This works quite well
    and puts out the attached text file.

    On occasion, the recieved text file will have some, all, or none of
    the fields quoted. In fact, it is QUITE possible to recive a text file
    where the quote is randomly scattered thruout the file.

    As can be expected this plays hob with the analysis program. To
    fix this particular problem, I decided to build a function which
    would take the input line, determine if there were quoted fields,
    determine if there were delimiters within the quoted fields and
    replace the actual delimiters with another character.

    People, it's a *************** zoo! Here are the possible
    scenarios:


    xxx,xxx,xxx,..... no quotes
    "xxx","xxx",..... quotes but no interior delimiters
    "xxx","xxx,yyyy",xxx ... quotes with interior delimiters
    xxx",xxx,xxx,xxx,xx"x, quotes that don't mean anything

    and variations on the theme.

    If anyone can come up with a algorithm I'd be eternally grateful.
    Well, at least grateful until Sunday a 2PM.

    Thank you
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  2.  

  3. #2
    Senior Member Katie's Avatar
    Join Date
    Mar 2002
    Location
    In the backyard! Come on out and help yourself to
    Posts
    771
    Member #
    31
    yikes, that's a nasty looking thing! I'll think about it.
    Does the moon actually possess strange powers or is it all just lunacy?

    Chris and Pix; the adorable duo!

  4. #3
    Senior Member Katie's Avatar
    Join Date
    Mar 2002
    Location
    In the backyard! Come on out and help yourself to
    Posts
    771
    Member #
    31
    Can you give us some more information please! All you want is a parser than will remove the quotes while maintaining the comma as the delimiter???
    Does the moon actually possess strange powers or is it all just lunacy?

    Chris and Pix; the adorable duo!

  5. #4
    Junior Member
    Join Date
    May 2002
    Location
    Canada!
    Posts
    6
    Member #
    100
    ya i am at a loss for information also. Please elaborate

  6. #5
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    Ok, I worked it out. I was right, too damn close to the problem.
    The solution is to split the string into a string array by the
    delimiter, and THEN check the beginning and ending of the
    subsequent array elements for quotes.

    Note that the delimiter does NOT change if the field spans more
    than one array element and there is a beginning and ending
    quote.

    Note that there is no limit to the number of characters in the
    delimiter.

    I'm also going to change it so that the quote string can be any
    set of characters.

    Using QuoteFld as a boolean that is initialized to False.
    OldMarker as the current Field delimiter
    NewMarker as a character(s) not found in the passed string (I
    wrote a function to do this .... it's guarranteed)

    Code:
    loop thru the array element by element
       If NOT quotefld: 
           is the first character(s) = Quote element(s)
                  yes:  set quotefld = true
                    no:  add the array element to the output string using
                                  NewMarker as a bound
           
       end if
       If Quotefld:
           is the last character(s)=Quote element(s)
                 yes:   set quotefld = false
                           add array element to a temporary string
                           add the temporary string to the output string using
                                  NewMarker as a bound
    
                   no:   add the array element to the Temporary  string
                                  using OldMarker as a bound
       end if
    
    loop
    
        check for unclose quoted strings
    
    return the string
    I've attached to code and the results of a test string.
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  7. #6
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    forgot to attach
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  8. #7
    Senior Member Katie's Avatar
    Join Date
    Mar 2002
    Location
    In the backyard! Come on out and help yourself to
    Posts
    771
    Member #
    31
    Glad to hear you worked it out! :thumbsup:
    Does the moon actually possess strange powers or is it all just lunacy?

    Chris and Pix; the adorable duo!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:55 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com