I'm parsing a file and need to keep track of where I am in the file... let's say I have file test.txt and I'm doing a while loop that reads in data constantly as each line is written to the file. In case of a crash I'm marking my position in another file with the tell() method of the file. Is there a way to mark the line and be able to go back to that line position or do I need to keep track of the bytes with tell only?
#this is just example code, not the real thing
f = open('test.txt')
pos = open('pos.txt', 'w')
f.seek(pos)
while 1:
readline(f)
pos.write(f.tell())
Update: the files are around 1GB each