CSV Error

Skip Montanaro skip.montanaro at gmail.com
Sun Dec 28 07:19:58 EST 2014


> 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

The file is only open during the context of the with statement. Indent the
last line to match the assignment to r and you should be fine.

Skip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141228/bee7e4ca/attachment.html>


More information about the Python-list mailing list