Commas in Comma Delimited Files

1

I have a SQL export that is comma delimited, but some of the data has commas in it. Is there any way to fix this? I'm guessing I am going to have to re-export the data with a different delimiter.

xxl3ww

Posted 2010-10-27T19:15:41.560

Reputation: 1 489

Answers

3

The specification of a CSV is that commas in data be quoted like this a,b,c,"d,e",f. If you can add the qoutes manually then you should be able to get the data to load.

To find lines that need fixing you could grep for lines with more commas than (columns -1).

Note that quoting data without commas is also permissible so if you can rewrite your extract to do this "a","b","c","d,e","f" it will also work (so long as there's no quotes in your data.)

Chris Nava

Posted 2010-10-27T19:15:41.560

Reputation: 7 009

1

If you surround the text fields that contain commas in the data with quotation marks, those commas should not be picked up as delimiters

BBlake

Posted 2010-10-27T19:15:41.560

Reputation: 5 120

0

Chris

Posted 2010-10-27T19:15:41.560

Reputation: 1 093

You should give a brief explanation about the contents of the link and why it is relevant just in case the link stops working for any reason. – MaQleod – 2010-10-27T19:31:37.570