[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-19 Thread Dong-hee Na

Dong-hee Na added the comment:

Oh, I read the Serhiy Storchaka 's comment just right now.

--

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-19 Thread Dong-hee Na

Dong-hee Na added the comment:

I would like to solve this issue. 
Is there any other way than casting specifically for the bool object?
(e.g For general ways?)

--
nosy: +corona10

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-19 Thread Dong-hee Na

Changes by Dong-hee Na :


--
pull_requests:  -1305

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-19 Thread Dong-hee Na

Changes by Dong-hee Na :


--
pull_requests:  -1303

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-19 Thread Dong-hee Na

Changes by Dong-hee Na :


--
pull_requests: +1305

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This issue is not easy, it needs a thoughtful design before starting coding. I 
agree with Xiang's analysis and proposed solutions. But if just convert numbers 
to float we can get an overflow for large integers or lost precision in case of 
Decimal. The consumer of the CSV file may be not Python and it may support 
larger precision than Python float.

And it is not clear what would be better solution for enums. Should they be 
serialized by name or by value?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-18 Thread Dong-hee Na

Changes by Dong-hee Na :


--
pull_requests: +1303

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-13 Thread Xiang Zhang

Xiang Zhang added the comment:

boolean is not quoted since in Python it's a subclass of int so True and False 
are numeric. This is also the case with numeric objects defining __int__ or 
__float__ but doesn't get a corresponding string representation.

Since QUOTE_NONNUMERIC will converts data to float when reading, I think we may 
force the converting even when writing so the inconsistency would disappear. Or 
document this limitation.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue30046] csv: Inconsistency re QUOTE_NONNUMERIC

2017-04-11 Thread Thomas Lotze

New submission from Thomas Lotze:

A csv.writer with quoting=csv.QUOTE_NONNUMERIC does not quote boolean values, 
which makes a csv.reader with the same quoting behaviour fail on that value:

 csv.py --

import csv
import io


f = io.StringIO()

writer = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC)
writer.writerow(['asdf', 1, True])

f.seek(0)
reader = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)
for row in reader:
print(row)

--

$ python3 csvbug.py 
Traceback (most recent call last):
  File "csvbug.py", line 12, in 
for row in reader:
ValueError: could not convert string to float: 'True'

--

I'd consider this inconsistency a bug, but in any case something that needs 
documenting.

--
components: Library (Lib)
messages: 291516
nosy: tlotze
priority: normal
severity: normal
status: open
title: csv: Inconsistency re QUOTE_NONNUMERIC
type: behavior

___
Python tracker 

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