ducklet

guide

How to query a CSV with SQL in your browser

Run SELECT, GROUP BY and JOIN on a CSV file with DuckDB in the browser: no database, no install, no upload. A short walk-through with examples.

You have a CSV and a question. A spreadsheet is slow at this size, and setting up a database for one file is a chore. DuckDB reads a CSV directly with SQL, and ducklet runs DuckDB inside your browser tab, so the whole job takes a minute and the file never leaves your computer.

1. Open the file

Go to Query a CSV with SQL and drop your file on the box, or paste the https address of a public one. It lands in data/ in a project that lives in your browser's own storage, so it is still there tomorrow.

2. Ask your question

DuckDB reads a file by its path, so the file is the table:

SELECT channel, sum(revenue) AS revenue
FROM 'data/campaigns.csv'
GROUP BY channel
ORDER BY revenue DESC

It works out the delimiter, the header and each column's type. When it guesses wrong, say so:

SELECT * FROM read_csv('data/export.csv', delim = ';', header = true, dateformat = '%d/%m/%Y')

3. Join it to something else

Two files join like two tables, even when one is Parquet:

SELECT o.region, count(*) AS orders, sum(o.total) AS total
FROM 'data/orders.csv' AS o
JOIN 'data/regions.parquet' AS r USING (region_id)
GROUP BY ALL

DuckDB's SQL has window functions, PIVOT, QUALIFY, list and struct types, and regular expressions, so most questions fit in one query.

4. Keep it, chart it, share it

Save the query as queries/by_channel.sql. In the terminal, chart bar queries/by_channel.sql pins it as a chart, and chart link makes a dashboard where a click on one chart filters the others. When it's ready, share it as a link or as a single HTML file (see Share a data app as a link).

open 📝 Scratch: campaign revenue →about this app ›try it with your own file: Query a CSV with SQL ›