Query a CSV File with SQL
Run SQL on CSV files in your browser with DuckDB. Filter, group, sort and join CSVs, then export results. Nothing is uploaded and nothing to install.
Sometimes you just want to ask a CSV a question: how many rows match, what's the total per month, which values are duplicated. Loading it into a database is overkill and spreadsheets get slow. Drop the file in the SQL Playground and it becomes a table you can query straight away.
How it works
- Drop one or more .csv or .tsv files into the SQL Playground.
- Each file becomes a table named after the file (orders.csv becomes orders). Column types are detected automatically.
- Write SQL, run it, and export the full result as CSV, JSON or Parquet.
Examples you can copy
Monthly totals
SELECT date_trunc('month', order_date) AS month,
SUM(quantity * unit_price) AS revenue
FROM orders
GROUP BY month
ORDER BY month;
Find duplicate values
SELECT customer_id, COUNT(*) AS n
FROM orders
GROUP BY customer_id
HAVING COUNT(*) > 1
ORDER BY n DESC;
Read a CSV with options directly
SELECT *
FROM read_csv('orders.csv', header = true, delim = ',')
LIMIT 20;
FAQ
How do I run SQL on a CSV file online?
Open the SQL Playground, drop your CSV file, and query it by its file name, for example SELECT * FROM orders LIMIT 10. Everything runs inside your browser.
Does it detect column types?
Yes. DuckDB samples the file to detect the delimiter, header and column types such as numbers, dates and text. You can override this with read_csv options if needed.
Can I query several CSV files at once?
Yes. Every file you add becomes its own table, and you can JOIN or UNION them in one query.
What if my CSV won't load correctly?
Check it with the CSV & Delimited File Doctor first. It finds broken quotes, mixed delimiters and encoding problems before you query.
Open the SQL Playground
Explore the local data workbench ยท Browse all tools