Skip to content
SQL on CSV files

Run SQL queries on a CSV file

Load a CSV and query it as a table called csv. It's real SQLite running in your browser, so GROUP BY, CASE, subqueries and window functions all work, with no database to install.

Free. No sign-up. Opens with a sample GROUP BY query you can edit.

How it works

  1. Load your CSV

    Drop a file on the Open file step. Its header row becomes the column names of a table you query as csv.

  2. Write a query in a Custom SQL step

    The sample first adds an age_group column with a Calculate step, then a Custom SQL step runs GROUP BY age_group, region with AVG(income) and COUNT(*).

  3. Chain or export the result

    The result is a new table. Add another step below it to keep going, or export it as CSV, Excel or HTML.

CSV Notebook with census sample data, a Calculate step and a Custom SQL step grouping by age group and region

Why CSV Notebook

  • Private

    Runs in your browser. Your files are never uploaded, so nobody else can see them.

  • Repeatable

    No AI and no guesswork: the same steps on the same file give the same result every time. Your steps are saved as a notebook in your browser. Next month, open it and drop in the new file: if a column was renamed, the step that needs it stops with an error that names it, and Pro can map it for you.

  • Auditable

    Every transformation step is SQL you can read, so you can check exactly what happened to your data. Each step also shows a preview of its output and a summary of what it did, so you can see the result before you export.

Worked example

census_tract_data.csv
tract_idregionageincome
1001North2555000
1001North45120000
1002South150
1002South4275000
1003North7062000
1003North6860000
1004West3088000
1004West3595000
After GROUP BY age_group, region
age_groupregionavg_incomecount
18-29North550001
30-49North1200001
30-49South750001
30-49West915002
65+North610002
Under 18South01

The query is SELECT age_group, region, AVG(csvn_num(income)) AS avg_income, COUNT(*) AS count FROM csv GROUP BY age_group, region ORDER BY age_group, region; Change it, and the result updates when you run the step.

Edit the sample query

The notebook opens with census sample data and a GROUP BY query. Rewrite the SQL, or drop in your own CSV and start from SELECT * FROM csv.

Open in CSV Notebook

Frequently asked questions

Which SQL dialect does it use?

SQLite 3.45, compiled to WebAssembly (sql.js). You get the usual SQLite functions such as strftime, ROUND, COALESCE and CASE, plus window functions like ROW_NUMBER() OVER (...).

How do I compare numbers safely?

CSV Notebook stores every value as the exact text in your file, so a ZIP code like 02134 never loses its zero. A comparison such as age < 30 can then compare text, where '9' sorts after '30'. SQL's CAST(age AS INTEGER) fixes that but turns a blank or abc into 0. Use csvn_num(age) instead: it gives the number, or nothing for anything that isn't a plain number. The sample does this, so a missing age lands in Unknown rather than Under 18.

Can I start my query with WITH?

Not at the very start: the Custom SQL step already wraps your query as WITH csv AS (...). Use a subquery in FROM (...) instead, which works the same way.

Can I query two CSV files together?

Load the second file with a Join step first. The Custom SQL step below it then sees the joined result as csv. See joining CSV files for how the Join step works.

Is my data sent to a server?

No. The database lives in your browser's memory and is rebuilt from your file each time you open the notebook. Your queries and results never leave your computer.