0

Can anyone tell me how to open a big/large file with python without loading it to the memory ?

this is my code:

# Open the input_file
with open(args.input_file) as input_file:
    log = input_file.read()

thanks

Elhabib
  • 39
  • 3
  • 2
    Does this answer your question? [Read file in chunks - RAM-usage, read Strings from binary files](https://stackoverflow.com/questions/17056382/read-file-in-chunks-ram-usage-read-strings-from-binary-files) – Random Davis Nov 17 '20 at 16:20
  • 3
    The `input_file` object is an iterator that you can iterate over line by line. That way, you can process the entire file by working on it one line at a time without having to save the entire file in memory. – Pranav Hosangadi Nov 17 '20 at 16:21

0 Answers0