# StringSplit on comma but ignore commas in quotes [closed]

I'm importing CSV files and some of the fields include quoted text with commas as part of the field, rather than as a field separator. What is the syntax (or alternative method entirely) to import and split the string by comma, while ignoring commas within quotes?

raw = ReadList[file, String];
StringSplit[raw[[#]], ","] &/@Range@Length@raw


This splits each line of the file on commas, but for lines like:

a,b,"c,c",d,e


I get:

a
b
"c
c"
d
e


whereas I would like:

a
b
"c,c"
d
e


(I have represented the elements of the example line as a column to emphasize unique fields)

## closed as off-topic by MarcoB, m_goldberg, user9660, Alexey Popkov, Michael E2Jun 30 '16 at 0:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, m_goldberg, Community, Alexey Popkov, Michael E2
If this question can be reworded to fit the rules in the help center, please edit the question.

• I think if your provide your CSV files,you will get more beauty solution – yode Jun 28 '16 at 18:38
• @yode - we can try to just experiment with the one line, StringSplit["a,b,\"c,c\",d,e", ","]  to try and get it to work – Jason B. Jun 28 '16 at 18:41
• – Szabolcs Jun 28 '16 at 18:54