fixing an horrific formatted csv file.
Gregory Ewing
greg.ewing at canterbury.ac.nz
Fri Jul 4 02:19:09 EDT 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.
--
Greg
More information about the Python-list
mailing list