Regular expression help, splitting csv text lines

Post Reply
barry.marcus
Posts: 288
Joined: Thu Nov 16, 2006 1:05 pm

Regular expression help, splitting csv text lines

Post by barry.marcus »

Is there a way to split lines of comma-separated text into individual strings, except when the commas are somewhere between quotes? For example, given this line:

"test",a,20110101,"hello there, my friend",,b

I want to split it into these six strings:

"test"
a
20110101
"hello there, my friend"

b

Note that the empty strings are significant. After the split I'll strip all beginning and ending quotes from the individual strings. That I can handle! I just can't seem to figure out how to do the split.

As always, I appreciate your assistance.
User avatar
John
Site Admin
Posts: 2597
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Regular expression help, splitting csv text lines

Post by John »

There is a <split> command in Vortex which will do that.
John Turnbull
Thunderstone Software
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

Regular expression help, splitting csv text lines

Post by mark »

<split> won't handle the embedded , as desired. You'll need to use <timport> with "csv" to properly parse the csv.
Post Reply