[Csv] PEP 305

Roberto Bonato robonato at tiscali.it
Thu Oct 2 15:43:22 CEST 2003


Hi Skip

        thank you very much for your help, I'll try and use your script, 
of course I had thought about writing that on my own, but this will 
spare me some work.

        One last question: I thought that the "doublequote" flag in the 
definition of the Dialect class was supposed to deal with "dirty" .csv 
files like mine (regarding the inner double quotes, not the leading and 
trailing ones). So what is that flag useful for?

Roberto

Skip Montanaro wrote:

>(Let's keep csv at mail.mojam.com in the loop.  This is good input for all of
>us.) 
>
>    >> Using the attached CSV file (which I think is correct and uses your
>    >> screener object, I get
>    >> 
>    >> ['INTC', 'Intel Corporation', '1', '2,07', '0,22', '13,00', '53', '669', '700', '28,37']
>    >> 
>    >> which looks fine to me.
>    >> 
>    Roberto> but it doesn't to me, because 53, 669, 700 are not three
>    Roberto> different data, but the single number 53669700, only, as you
>    Roberto> can see in the following line, is represented with dots as
>    Roberto> usual in financial conventions.
>
>I understand that it wasn't quite right.  I had to guess about the quoting.
>It's still all wrong.  It's not just that there are extra quotation marks at
>the beginning and the end (the ones you stripped), it's that every other
>quotation mark is doubled.  The parser only supports a single character
>quote character, so they are a problem.
>
>One thing you can do to make like easier is to write a generator function
>which sits between the file and the parser.  It will strip the extra quotes
>in each line.
>
>I've attached a simple Python script (which requires Python 2.2 or 2.3) that
>seems to work correctly, as well as your longs.csv file (with the extra
>leading and trailing triple quotes) so the other developers can see it.
>
>Skip
>
>  
>




More information about the Csv mailing list