Parsing CSV Files

January 19, 2010

I use split quite a bit for string manipulation and ran into an interesting issue the other day with it when parsing a CSV file with a multi-value field that itself contained comma delimited data.

For example….

214,Bob,Johnson,12/28/1968,(Florida,Texas,Washington),$3,444,234.03

RegEx to the rescue….

Dim re
 Set re = new RegExp
 re.Global = true
 re.pattern = ",(?=[^()]*\))"
 re.Replace(strInput, "|")
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.