# Agent Crashed Parsing A 2gb Usage CSV 8655bd628ed6e762

> Fixes an agent crashing with out-of-memory errors parsing a very large usage CSV by streaming the file in chunks and aggregating incrementally. Use when usage files exceed memory. Not for a file that is large because it is the wrong export entirely.

- Skill: `vectle/agent-crashed-parsing-a-2gb-usage-csv-8655bd628ed6e762` (Agent Skill)
- Install (CLI): `npx get-skill add vectle/agent-crashed-parsing-a-2gb-usage-csv-8655bd628ed6e762`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vectle/agent-crashed-parsing-a-2gb-usage-csv-8655bd628ed6e762/raw
- Safety review: pending (external: skill-scanner PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: Vectle (https://skillmd.com/u/vectle)
- Updated: 2026-11-19
- Page: https://skillmd.com/skills/vectle/agent-crashed-parsing-a-2gb-usage-csv-8655bd628ed6e762

---


## TL;DR
Loading a 2GB CSV whole guarantees the crash; the data per account is what matters, not the file. Stream the file row by row with a chunked reader, accumulate only per-account aggregates, spill intermediate results to disk if they grow, and the same job runs in a fraction of the memory regardless of file size.

```text
agent crashed parsing a 2GB usage CSV: out of memory error
```

## Use this when
- The agent dies with memory errors on large usage exports
- Smaller files from the same source process fine
- Memory climbs steadily until the crash

## Not for this skill when
- The file is corrupt and the parser loops on one record, inflating memory
- The aggregates themselves (millions of accounts) genuinely exceed memory and need a database

## Steps
1. Confirm the crash pattern: memory growth tracks file reading, and the file parses fine in a streaming test read. Verify: the whole-file load is convicted as the cause
2. Rewrite ingestion with a chunked or streaming reader and verify peak memory on the full file. Verify: the full file processes within a bounded memory footprint
3. Replace row storage with incremental per-account aggregation during the stream. Verify: memory no longer scales with row count
4. If aggregates still grow large, spill them to a local database or disk-backed store mid-run. Verify: the job scales to the real account count without redesign
5. Add a pre-flight file-size check that selects the streaming path automatically for large inputs. Verify: no future big export can re-trigger the crash by surprise

## Variant phrasings
### agent out of memory 2GB CSV
A related phrasing for the same underlying problem.
### stream large usage file parsing
A related phrasing for the same underlying problem.
### chunked CSV aggregation agent
A related phrasing for the same underlying problem.

Compatibility: Compatibility: large CSV usage exports processed in Python (pandas chunking, csv streaming) or similar runtimes, current versions.

## Why it happens
Memory failures on growing files are inevitable with whole-file designs; the file always eventually wins. Streaming with incremental aggregation changes the scaling law from file size to aggregate size, which for usage data is orders of magnitude smaller and stable.

## Edge cases / pitfalls
- pandas read in chunks still concatenates badly if you accumulate frames. Accumulate aggregates, not chunks.
- Malformed rows inside a huge file need a counted quarantine, not an exception that wastes a long run.
- Compression helps transfer, not memory: a gzipped 2GB CSV expands to the same problem. Stream the decompression too.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_4MRcaMDr1Fgdhu6wgCee3g


---

Source: [Vectle](https://vectle.com/skills/skl_SLrV_vBhm2chnzUiaccpog). Version: `skv_1RUGE00mVE18Lq9XhH4VOA`. Original contributor attribution is preserved in the frontmatter. Content remains subject to [Vectle’s terms](https://vectle.com/terms) and its contributors’ rights; this mirror does not grant a new content license.

