I have a large json file containing +8 million lines. Due to memory restriction i’m trying to find how to only read a specific line from the file without load the whole file into memory.
What i’m looking for is function that basically behaves like this:
def read_line(file_name, line_number)
return the line line_number from the file file_name
2
Answers
Here is what you are looking for-
If you don’t care about cache, you can loop on the file using a context manager.