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.
3 Answers
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.)
If you surround the text fields that contain commas in the data with quotation marks, those commas should not be picked up as delimiters
Take a look here, is this what you want?
-
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.– MaQleodOct 27, 2010 at 19:31