I need to know how to read lines from a file in python so that I read the last line first and continue in that fashion until the cursor reach\'s the beginning of the file. A
You can also use python module file_read_backwards. It would be read in a memory efficient manner. It works with Python 2.7 and 3.
It supports "utf-8","latin-1", and "ascii" encoding. It will work with "\r", "\n", and "\r\n" as new lines.
After installing it, via pip install file_read_backwards (v1.2.1), you can read the entire file backwards (line-wise) via:
#!/usr/bin/env python2.7
from file_read_backwards import FileReadBackwards
with FileReadBackwards("/path/to/file", encoding="utf-8") as frb:
for l in frb:
print l
Further documentation can be found at http://file-read-backwards.readthedocs.io/en/latest/readme.html