Reader not iterable on Python3
jruere opened this issue · 3 comments
jruere commented
This works on Python2 and with the build in module.
Python 3.4.3 (default, Mar 25 2015, 17:13:50)
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import unicodecsv
>>> import io
>>> r = unicodecsv.reader(io.BytesIO(b"hello,world"))
>>> list(r)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: iter() returned non-iterator of type 'UnicodeReader'
tsroten commented
The reason why this is happening is that __next__()
is not defined for the UnicodeReader
. Python 2 uses the next()
method and Python 3 uses the __next__()
magic method. Unfortunately, that's the least of the problems with unicodecsv
's UnicodeReader
iterating in Python 3. The other problems are:
- the
self.reader.next()
method call (should benext(self.reader)
in Python 3) - the call to
unicode()
- also, you'd need to use
io.StringIO()
, notio.BytesIO()
in Python 3
jruere commented
OK, I guess it's not quite ready yet. :)
jdunck commented
I've added py3 in 0.12.0 - please try it out and open another issue if you find specific problems. :)