[issue32919] csv.reader() to support QUOTE_ALL

2018-03-05 Thread Pavel Shpilev

Pavel Shpilev  added the comment:

I know that CSV specification says empty field and empty string are the same, 
however, I still believe there is practical use for unconventional processing 
of such fields.

In our specific case we parse CSVs produced by Amazon Athena (based on Presto) 
in which NULL and empty string values represented as above. Following CSV specs 
dogmatically, there's no way to distinguish between the two, but pragmatically 
you can tell them apart by simply looking at values.

Brief search shows we aren't the only ones facing the issue. After giving it 
some more thought, I'd agree that csv.QUOTE_ALL doesn't make much sense here, 
but may be an extra argument to csv.reader() will do the trick? Something like 
csv.reader(detect_none_values=False/True), with False being default, and 
emphasis in the documentation that True goes against CSV specification.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32919] csv.reader() to support QUOTE_ALL

2018-03-03 Thread R. David Murray

R. David Murray  added the comment:

QUOTE_ALL only makes sense as an output control parameter, IMO.  It is an 
output discipline but doesn't say anything about semantics.  In csv format, an 
empty field and a field containing the empty quoted string are completely 
equivalent.  I would be -1 on adding an option that differentiated them.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32919] csv.reader() to support QUOTE_ALL

2018-02-22 Thread Pavel Shpilev

New submission from Pavel Shpilev :

It appears that in current implementation csv.QUOTE_ALL has no effect on csv. 
reader(), it only affects csv.writer(). I know that csv is a poorly defined 
format and all, but I think this might be useful to distinguish None and '' 
values for the sources that use such quoting.

Example:

"1","Noneval",,"9"
"2","Emptystr","","10"
"3","somethingelse","","8"

Reader converts all values in the third column to empty strings. The suggestion 
is to adjust reader's behaviour so when quoting=csv.QUOTE_ALL that would 
instruct reader to convert empty values (like the one in the first row) to None 
instead.

--
components: Extension Modules
messages: 312617
nosy: Pavel Shpilev
priority: normal
severity: normal
status: open
title: csv.reader() to support QUOTE_ALL
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com