Trying to fix Invalid CSV File

Ryan Rosario uclamathguy at gmail.com
Sun Aug 3 23:43:54 EDT 2008


I have a very large CSV file that contains double quoted fields (since
they contain commas). Unfortunately, some of these fields also contain
other double quotes and I made the painful mistake of forgetting to
escape or double the quotes inside the field:

123,"Here is some, text "and some quoted text" where the quotes should
have been doubled",321

Has anyone dealt with this problem before? Any ideas of an algorithm I
can use for a Python script to create a new, repaired CSV file?

TIA,
Ryan



More information about the Python-list mailing list