[Csv] Re: First Cut at CSV PEP

Cliff Wells LogiplexSoftware at earthlink.net
Thu Jan 30 22:45:53 CET 2003


On Thu, 2003-01-30 at 13:02, Skip Montanaro wrote:
>     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 ''.

The database not being able to distinguish '' from SQL NULL is inherent
in the file format.  CSV files have no concept of '' vs None vs NULL. 
There is only ,, or ,"", which I think should be considered the same
(because the same data [or lack of] can be expressed either way by
tweaking the quote settings).

If we don't want them to be considered the same, then we need YAO to
specify whether to interpret them differently.  

> 
>     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.

Well, right =)

> 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'

This seems reasonable.

> in the writer() constructor and
> 
>     interpret_empty_string_as=<any object, maybe None>
> 
> in the reader() constructor.

Okay.

> Skip

Sure.


-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308



More information about the Csv mailing list