← Back to Node.js Challenges
Node.jsAdvanced
Parse Large CSV Files with Streams
Essential for backend interviews to prove you understand memory management and non-blocking I/O.
Problem Statement
Write a Node.js script that reads a 5GB CSV file containing user data, extracts users from 'New York', and writes them to a new file, without running out of RAM (heap memory).
Real World Scenario:
Data pipelines constantly process massive files. If you use `fs.readFileSync()`, the entire 5GB file loads into RAM, immediately crashing the Node server.
Input / Output
Input: A file `users.csv` with 50 million rows.
Output: A file `ny_users.csv` containing only the filtered rows.
Constraints
- You cannot load the entire file into memory.
- You must use the `fs` and `stream` modules.
- Max memory usage must stay under 50MB.
Interactive Playground
Loading...
Console Output
Click "Run Code" to see the output here.