This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tlotze
Recipients tlotze
Date 2017-04-11.20:41:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491943315.79.0.569209717832.issue30046@psf.upfronthosting.co.za>
In-reply-to
Content
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 <module>
    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.
History
Date User Action Args
2017-04-11 20:41:55tlotzesetrecipients: + tlotze
2017-04-11 20:41:55tlotzesetmessageid: <1491943315.79.0.569209717832.issue30046@psf.upfronthosting.co.za>
2017-04-11 20:41:55tlotzelinkissue30046 messages
2017-04-11 20:41:55tlotzecreate