Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Processing files that are too big to fit into memory

The article discusses techniques for handling large files that exceed available memory, focusing on reading and processing data in chunks rather than loading the entire file at once. It covers practical approaches such as using iterators, streaming, and memory-mapped files to efficiently work with big datasets in programming.

Background

- The article walks through techniques for handling files larger than available RAM, written as a practical engineering guide for programmers. - Core problem: loading an entire CSV, log, or database dump into memory causes crashes or swapping; alternatives include streaming, memory-mapping, chunking, and using databases or columnar formats. - Key approaches covered: reading line-by-line (lazy I/O), `pandas.read_csv(..., chunksize=...)`, Python generators, memory-mapped files (`mmap`), SQLite for disk-backed queries, and Apache Arrow / Parquet for columnar storage. - Assumes basic Python proficiency; the reader is expected to know what RAM, CSV, and a Python script are, but not how to handle multi-GB files on a single machine. - No prior news context is needed — this is a perennial, language-agnostic software engineering topic.

Related stories