Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

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.)

share|improve this answer
add comment

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

share|improve this answer
add comment

Take a look here, is this what you want?

http://www.talkphp.com/absolute-beginners/5072-importing-comma-delimited-csv-file-containing-commas.html

share|improve this answer
    
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 Oct 27 '10 at 19:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.