Possible Duplicate:
python: how to jump to a particular line in a huge text file?
I'm trying to read various lines out of a large (250Mb) file.
The header tells me where certain parts are, i.e. the history subsection of the file starts at byte 241817341.
So is there a way to read the file only starting at that byte, without having to go through the rest of the file first? Something like:
file = open(file_name,'r')
history_line = file.readline(241817341)
while history_line != 'End':
history_line = file.readline()
[Do something with that line]
Is that sort of thing feasible?
f.seek(0)
print f.readline()
>>> Hello, world!
f.seek(4)
print f.readline()
>>> o, world!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With