[Csv] Re: First Cut at CSV PEP

Skip Montanaro skip at pobox.com
Thu Jan 30 22:02:27 CET 2003


    Cliff> Export is a slightly different story.  I do think None should be
    Cliff> mapped to '' on export since that is the only reasonable value
    Cliff> for it, and there are enough existing modules that use None to
    Cliff> represent an empty value that this would be a reasonable thing
    Cliff> for us to handle.

How is a database (that was Dave's use case) supposed to distinguish '' as
SQL NULL vs '' as an empty string though?  This is the sort of thing that
bothers me about mapping None to ''.

    Cliff> This might not affect performance too badly if we *always* raise
    Cliff> an exception when passed anything but a string, ...

except float and int values will be prevalent in the data.

Can we limit the data to float, int, plain strings, Unicode and None?  If
so, I think you can just test the object types and do the right thing.  In
the case of None, I'd like to see a parameter which would allow me to flag
that as an error.  The extra complication might be limited to

    map_none_to='some string, possibly empty'

in the writer() constructor and

    interpret_empty_string_as=<any object, maybe None>

in the reader() constructor.

Skip


More information about the Csv mailing list