Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

Take a look here, is this what you want?

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .