python csv manipulation

Status
You're currently viewing only herko's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

herko

Tone down Your Control issues.
7,014
Moderator
Things that may break CSV readers, depending on the phase of the moon/tides/wishes of the insane monkey god:
  • Text that should be quoted, but isn't, and contains a comma
  • Paragraphs of text inside a single cell with newlines in it. Even properly quoted, it drivers some CSV readers (like Excel's) insane.
  • Non-ASCII characters
  • Nested quoting
  • Having Excel participate anywhere in the process
  • Having Excel installed on the same computer
  • Having Excel installed on the same network

Jokes aside, csv.reader (and my favorite, csv.DictReader) are stellar. You may need to tune it for the particular dialect of csv your file is written in. See Dialects and Formatting parameters.

CSV is an informal spec at best, and everyone implements it slightly differently. Rolling a csv reader to fit your exact format is trivial. Rolling a csv reader that tolerates the inconsistencies that exist out in the real world... isn't.

If you can post the offending .csv file, we might be able to help further.
 
Status
You're currently viewing only herko's posts. Click here to go back to viewing the entire thread.
Not open for further replies.