CSV module: incorrectly parsed file.

Andrew McNamara andrewm at object-craft.com.au
Mon Feb 18 03:25:59 CET 2008

>Here is a file "test.csv"
>1,"wer","tape 2"",5
>I want to convert it to tab-separated without those silly quotes. Note
>in the second line that a field is 'tape 2"' , ie two inches: there is
>a double quote in the string.

The input format is ambiguous - how is the parser to distinguish between
a double-quote in the field, and the double-quote that delimits the
field?  Excel would have written that field as "tape 2""" (it doubles
double-quotes that appear within a field).

You can turn off the double-double-quote handling by passing
"doublequote=False" to the parser, but the results still might not be
what you want (because the format is ambiguous).

Andrew McNamara, Senior Developer, Object Craft

More information about the Python-list mailing list