[New-bugs-announce] [issue5332] csv sniffer
David W. Lambert
report at bugs.python.org
Fri Feb 20 21:45:33 CET 2009
New submission from David W. Lambert <lambertdw at corning.com>:
Following instructions in
http://docs.python.org/dev/3.0/library/csv.html#module-csv
I opened file in binary mode. This might be simply a documentation
problem or it may run deeper. Text mode works on red hat linux system.
Here's the use:
>>> stream=open('csv','rb')
>>> dialect=csv.Sniffer().sniff(stream.read(1024))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/users/lambert/bin/python/lib/python3.0/csv.py", line 169,
in sniff
self._guess_quote_and_delimiter(sample, delimiters)
File "/usr/users/lambert/bin/python/lib/python3.0/csv.py", line 210,
in _guess_quote_and_delimiter
matches = regexp.findall(data)
TypeError: can't use a string pattern on a bytes-like object
Here's the conflicting documentation statement:
"If csvfile is a file object, it must be opened with the ‘b’ flag on
platforms where that makes a difference. ... see section Dialects and
Formatting Parameters.
All data read are returned as strings. No automatic data type conversion
is performed."
(Problem is that the binary file returnd data of type bytes.)
Thanks, Dave.
----------
components: Library (Lib)
messages: 82546
nosy: LambertDW
severity: normal
status: open
title: csv sniffer
type: behavior
versions: Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5332>
_______________________________________
More information about the New-bugs-announce
mailing list