How to read large files without loading into memory?
Answer
•Iterate over lines: for line in f:.
•For binary — read in chunks: f.read(8192).
•Use generators for pipelines.
•Do not do f.read() on gigabytes.
•For CSV — csv.reader line by line.
Was this answer helpful?