CSV Error

JC chalao.adda at gmail.com
Sun Dec 28 06:48:21 EST 2014


Hello,

I am trying to read a csv file using DictReader. I am getting error -

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    r.fieldnames
  File "/usr/lib/python2.7/csv.py", line 90, in fieldnames
    self._fieldnames = self.reader.next()
ValueError: I/O operation on closed file

Here is my code in a Python shell -

>>> with open('x.csv','rb') as f:
...     r = csv.DictReader(f,delimiter=",")
>>> r.fieldnames

I have tried to open the file in 'rU', 'r' mode. But still I am getting 
the above error.

Please help.
Thanks.



More information about the Python-list mailing list