fixing an horrific formatted csv file.

Gregory Ewing greg.ewing at
Fri Jul 4 08:19:09 CEST 2014

flebber wrote:
> so in my file I had on line 44 this trainer name.
> "Michael, Wayne & John Hawkes"
> and in line 95 this horse name. Inz'n'out
> this throws of my capturing correct item 9. How do I protect against this?

Use python's csv module to read the file. Don't try to
do it yourself; the rules for handling embedded commas
and quotes in csv are quite complicated. As long as
the file is a well-formed csv file, the csv module
should parse fields like that correctly.


More information about the Python-list mailing list