Streaming CSV import (Node streams)

7271
0

The first time a CSV import OOM’d a production process, I stopped trusting ‘just read it into memory’. Now I stream the upload to disk (or S3), stream-parse rows, and batch inserts into the DB. The win is that memory usage stays flat, even when the file is huge. I also validate per-row and collect rejected rows into an error report instead of failing the entire import. Backpressure matters here: await your DB writes so the parser doesn’t outrun your database. If performance becomes an issue, I add a small concurrency limit, but I never go fully unbounded. This keeps imports predictable, debuggable, and safe as data sizes grow.