Python 3.1 csv with gzip
Stefan Behnel
stefan_ml at behnel.de
Fri Sep 11 09:03:52 EDT 2009
dryfish wrote:
> Python 3.1.1 doesn't seem to be happy with the use of gzip.open with
> csv.reader.
>
> Using this:
>
> import gzip, csv, sys
>
> data = csv.reader(gzip.open(sys.argv[1]))
> for row in data:
> print(row)
>
> Will give this:
>
> Traceback (most recent call last):
> File "./a.py", line 6, in <module>
> for row in data:
> _csv.Error: iterator should return strings, not bytes (did you open
> the file in text mode?)
See codecs.EncodedFile().
Stefan
More information about the Python-list
mailing list