DEV Community

Cover image for Analyze 3.9 million rows with Claude without putting them in the chat
PetrJ
PetrJ

Posted on

Analyze 3.9 million rows with Claude without putting them in the chat

If you upload a big CSV to an AI chat, you hit the context limit fast. And even when it fits, you pay for every row in tokens.

There's a simpler way: let the AI work on the data in a sandbox and only bring the answer back to the chat. Here's how we did it with a month of New York taxi trips, step by step, with the real numbers.

What you need

  • Claude (any plan, the Free plan allows one custom connector) or ChatGPT with developer mode
  • A free WBX Sandbox account: https://sandbox.wbx.cz

Step 1: Add the connector (2 minutes)

In Claude, open Customize → Connectors → Add custom connector and paste:

https://sandbox.wbx.cz/mcp
Enter fullscreen mode Exit fullscreen mode

Claude opens a sign-in page, you approve access, done. Other clients (ChatGPT, Cursor, VS Code, Claude Code) are covered here: https://sandbox.wbx.cz/docs/connect

Step 2: Give it a link, not a file

The key is that the data never passes through the chat. Give the AI a URL and one rule:

Use WBX Sandbox to analyze all NYC taxi trips from September 2026: https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2026-09.parquet
Keep the data in the sandbox, don't load it into this chat. When are taxis busiest, and which pickup zones tip the most? Show me a chart.

Step 3: Watch what it does

In our run, Claude:

  1. created a sandbox (a small Linux VM),
  2. downloaded the 67 MB Parquet file inside the sandbox (7 seconds),
  3. installed DuckDB and ran two short Python scripts against the file,
  4. read back only the printed summaries.

About a minute later it answered with two charts:

  • Taxis are busiest at 6 pm (268,207 pickups that month) and quietest at 4 am (32,315).
  • By tip percentage, the Upper East Side leads (24.8% of the fare). By dollars, the airports win: JFK averages a $12.97 tip.

It also flagged the caveats itself: tips are only recorded for card payments, so cash tips are missing.

Step 4: Count the tokens

This is the part we wanted to measure. We exported the same file to CSV and counted tokens with tiktoken (cl100k):

Size
Rows 3,876,044
Data as CSV 413.6 MB ≈ 310,805,382 tokens
What the chat actually received (tool outputs) ≈ 2,300 tokens

No chat model can hold 310 million tokens. The sandbox doesn't need to: the code goes to the data, and only the results come back.

Why it works

The AI writes small programs instead of reading rows. Each program prints a few lines (counts, averages, top 10), and that's all that enters the context. A few habits make this reliable:

  • Say it explicitly: "Keep the data in the sandbox" or "print only summaries". Models follow it.
  • Use a format built for this. Parquet + DuckDB scanned 3.9M rows in under a second here.
  • Name the sandbox if you want to continue tomorrow: "use a sandbox called nyc-taxi". It falls asleep when idle and keeps the files, so the next chat can pick up where you left off.
  • No internet needed for private data: upload the file and ask for a sandbox without network access.

The same thing in Python

If you're building your own agent, the loop is short: give the model one tool, run_python(code), run the code in a sandbox, and return only the clipped output. We put a complete version (one file, about 160 lines, any OpenAI-compatible model) in our examples repo:

https://github.com/WBX-Sandbox/examples/tree/main/use-cases/ai-data-analyst

At the end it prints how many bytes stayed in the sandbox and how many characters went to the model.

Try it

Pick a dataset you've always wanted to ask questions about, give your AI the link, and add "keep the data in the sandbox". If you try it with something interesting, I'd like to see the numbers in the comments.

There's also a 60-second video of this run on our YouTube channel: the real recording, with the waiting shortened.

Top comments (0)