[docs] Documention bug

Owen Johnson owen at existence.com
Tue Aug 6 08:48:35 CEST 2013


On page:

http://docs.python.org/3.0/library/csv.html

Under Examples:

----
The simplest example of reading a CSV file:

import csv
reader = csv.reader(open("some.csv", "rb"))
for row in reader:
    print(row)
----

Code works in python 2, but in python 3, it throws error:

----
Traceback (most recent call last):
  File "WeeklyDepletionParser.py", line 3, in <module>
    for row in reader:
_csv.Error: iterator should return strings, not bytes (did you open
the file in text mode?)
----

Fix was straightforward to change parameter "rb" to "rt".

I am running:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Owen


More information about the docs mailing list