By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

How to parse a CSV that contains commas

gregerly
Expert 100+
P: 192
I'm having an issue parsing a CSV file in which some fields contain commas. My CSV looks something like this:

Expand|Select|Wrap|Line Numbers
  1. 123,asdflkj23klj,"Sept. 22, 2008",some field,one more field,"Aug 1,1983"
To parse my csv files I was reading it into an array with file(), and then looping the lines, exploding by comma, IE explode(',',$line), however this doesn't work as it will explode the commas in the date fields.

I guess my main question is how do I parse a CSV which may or may not contain comma's in some of the fields.

Thanks!
Sep 24 '08 #1
Share this Question
Share on Google+
2 Replies


MarkoKlacar
Expert 100+
P: 296
Hi,

Have a look at the string tokenizer.

Good luck...

/MK
Sep 24 '08 #2

P: 31
hi,
have a look at fgetcsv

regards
nelluru
Sep 24 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.