File object is not only an iterable, it is an iterator, which is why it can only traverse the file once. You may reset the file cursor with
Reference
http://stackoverflow.com/questions/16994552/is-file-object-in-python-an-iterable
.seek(0)
as many have suggested but you should, in most cases, only iterate a file once.Reference
http://stackoverflow.com/questions/16994552/is-file-object-in-python-an-iterable
Comments
Post a Comment