On: 'The Python CSV Module and Legacy Data'

P

Paddy McCarthy

Hi,
I read http://radio.weblogs.com/0124960/ which has a quoted number in
a csv file being interpreted as a string.
I checked it out with my csv2txt utility
(http://www.paddyx.pwp.blueyonder.co.uk/)
And that does seem to be the case.

Should this action not be thought of as an error?
If the csv module reads a quoted string shouldn't it present it
internally as a string?

Since the csv reader is intelligent, maybe the correct proceedure
would be for it to:
* If it only sniffs out numbers held in strings then change all
strings containing valid numbers to numbers.
* If it initially sniffs out unquoted numbers, or no numbers at all,
or a mixture of quoted and unquoted numbers, then return un-quoted
numbers as numbers and quoted numbers as strings.

Or we could explicitely tell the CSV module what to do with quoted
number strings!

I haven't checked what the csv writer does with a string that could
also represent a number. Will it quote that on output? hmmm...

Cheers, Paddy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top