Python
All Top 50 Python & Pandas Interview Questions#7
Memory-Efficient Data Streaming with Generators in Python
MediumAmazonInterview Question #7
Asked at AmazonExplain how to read a 20GB log file in Python on a machine with only 4GB of RAM without crashing. Write a generator function that yields parsed JSON logs one by one.
Input Table: massive_file
1 rows preview| file_size | available_ram |
|---|---|
| 20 GB | 4 GB |
Expected Output Structure1 rows
| memory_behavior |
|---|
| Constant ~10MB RAM usage |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
Python 3.10 (Pandas)
Environment Ready
Click "Run & Test" to execute your Pandas code against the test assertions.