On: 'The Python CSV Module and Legacy Data'

Discussion in 'Python' started by Paddy McCarthy, Apr 26, 2004.

  1. 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.
     
    Paddy McCarthy, Apr 26, 2004
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?aW5ldG11Zw==?=
    Replies:
    0
    Views:
    524
    =?Utf-8?B?aW5ldG11Zw==?=
    May 27, 2005
  2. Stylus Studio
    Replies:
    0
    Views:
    674
    Stylus Studio
    Oct 5, 2004
  3. Daniel Ortmann
    Replies:
    4
    Views:
    823
    Skip Montanaro
    Jul 2, 2003
  4. Tintin92
    Replies:
    1
    Views:
    2,148
    Andrew Thompson
    Feb 14, 2007
  5. jliu66
    Replies:
    0
    Views:
    765
    jliu66
    Oct 19, 2007
  6. inetmug
    Replies:
    2
    Views:
    350
    inetmug
    Jun 3, 2005
  7. inetmug
    Replies:
    0
    Views:
    186
    inetmug
    May 27, 2005
  8. Sacha Rook

    csv read clean up and write out to csv

    Sacha Rook, Nov 2, 2012, in forum: Python
    Replies:
    2
    Views:
    467
    Hans Mulder
    Nov 2, 2012
Loading...