I'm looking to achieve two things, reading large files which I've read up using mmap
is suitable for this and reading the file in reverse (starting from the last line working up to the top).
I've tried both ways separately as follows:
f = open('syslog')
s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
#mmap method
for line in iter(s.readline, ""):
#search for string
#reading in reverse
for line in reversed(f.readlines()):
#search for string
I'm struggling to incorporate both of these into the one and not sure of the best way to approach this.
Any help would be appreciated.
Cheers