[Csv] PEP 305
Skip Montanaro
skip at pobox.com
Thu Oct 2 15:36:01 CEST 2003
(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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: longs.csv
Type: application/octet-stream
Size: 7191 bytes
Desc: not available
Url : http://mail.python.org/pipermail/csv/attachments/20031002/ad8c415d/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: longs.py
Type: application/octet-stream
Size: 658 bytes
Desc: not available
Url : http://mail.python.org/pipermail/csv/attachments/20031002/ad8c415d/attachment-0001.obj
More information about the Csv
mailing list