Having an issue with a custom iterator in that it will only iterate over the file once. I am calling seek(0)
on the relevant file object in between iterations, but
The DictReader
object does not appear to follow a seek()
command on the open file, so the next()
calls are continually made from the end of the file.
In your reset
you could reopen the file (you will also need to store the filename in self._filename
):
def reset(self):
if self._file:
self._file.close()
self._file = open(self._filename, 'rb')
You could also look at subclassing your file object similarly to the top answer to this question.