Results 1 to 6 of 6

Thread: Help with Split function

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Help with Split function

    Hi all,

    I have got a comma delimited file which uses quotes as text qualifiers. for example "Mr XXXXX","XX Street","" ....

    I am using the split function to store values in a string array but my problem is when i have a field that contains a comma within the quotes eg. "XX, Street". It splits these in to different array positions.

    Is there any way of avoiding this?

    Thanks for your help.

    Cheers

  2. #2
    Addicted Member
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    198

    Re: Help with Split function

    Hi Gogi,

    Im not all to familiar with that Split function, are there parameters you can add?

    If not i suggest making your own functions that would save everything within the "quotes".

    GL, Figa

    This wont work?
    Split(""a,d","b","c"" , """")
    Last edited by figa; Dec 21st, 2006 at 09:13 AM.

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Re: Help with Split function

    Hi Figa

    I am kind of working on my own function, but was wondering whether there is an easy way already out there. No point in reinventing the wheel :-))

    thanks

  4. #4
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: Help with Split function

    The proper way would be to use regex but I can't provide you with a suggestion as it's beyond me. In the spilt function you can use whole strings as a delimiter, not just single characters. So, use ","(in code """,""") as a delimiter instead of just the comma.

    You will still have to take care of the quotations marks (remove them from the first and last splitted strings or add them to all the strings in between respectively). Or wait for a regex suggestion.
    VB 2005, Win Xp Pro sp2

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Re: Help with Split function

    Hi Half

    thanks for the reply. I have been experimenting along those lines.

    cheers

    tolga

  6. #6
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Help with Split function

    Check out one of my codebank submissions in my sig, there is a CSV and TAB file parser that utilizes Regex. Feel free to use the code or just use it as a reference...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width