CSV module: incorrectly parsed file.

Andrew McNamara andrewm at object-craft.com.au
Sun Feb 17 21:25:59 EST 2008


>Here is a file "test.csv"
>number,name,description,value
>1,"wer","tape 2"",5
>1,vvv,"hoohaa",2
>
>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
http://www.object-craft.com.au/



More information about the Python-list mailing list