1. Home
  2. Spreadsheets & Data
  3. Query CSV with SQL

Query CSV with SQL

Run SQL on CSV, Excel and Parquet files and download the results.

Runs in your browser · No upload

How to use

  1. Drop or choose one or more CSV, TSV, XLSX or Parquet files. Each file becomes a table (one per sheet for Excel).
  2. Check the Loaded tables list for each table’s name, column names with inferred types, and row count. Remove tables you do not need with the trash button.
  3. The Example queries buttons (first 10 rows, sum by group, join two files) fill in a query using your real table and column names. Edit it freely.
  4. Press Run or Ctrl+Enter, then download the result as CSV (with BOM), XLSX or JSON. Open in another tool passes the result as CSV to the workspace page so you can continue in a tool such as CSV to Chart.

How files become tables

Item Rule
Table name The file name without its extension, keeping only letters, digits and _. sales-2026.csv becomes sales_2026; a leading digit gets a t_ prefix, so 2026 매출.csv becomes t_2026_매출. Clashing names get _2, _3
Excel sheets Named file_sheet: the Sales 1 sheet of book.xlsx becomes book_Sales_1. Empty sheets are skipped
Header If the first row looks like a header it names the columns; otherwise columns are called Col 1, Col 2 and so on. Names that differ only by case are split as name (2)
Column type INTEGER if every value is a whole number, REAL if decimals appear, otherwise TEXT. Numbers with commas such as 1,234 count as numbers
Kept as text Values with leading zeros (01234), values starting with +, exponent forms like 12E3 and numbers of 16 or more digits are likely ZIP codes, phone numbers or product codes, so they stay TEXT exactly as written
Dates A column made only of values like 2026-10-07, 2026.10.7 or 2026/1/2 03:04:05 is stored as ISO text, e.g. 2026-10-07 or 2026-01-02 03:04:05. Excel date cells too
Booleans, blanks Excel TRUE/FALSE become 1/0; blank cells become NULL

Values are inserted as bound parameters, and table and column names are double-quoted, so quotes or SQL inside a value or a header cannot change a statement. Rows go in 10,000 at a time, one transaction per batch.

When SQL beats a spreadsheet

  • Matching two files on a key (one JOIN instead of dragging VLOOKUP down ten columns)
  • Totals, counts and averages per group in one go (GROUP BY)
  • Complicated filters, finding duplicates (GROUP BY … HAVING COUNT(*) > 1), or window functions

For example, load orders.csv (id, customer_id, zip, amount, ordered_at) and customers.csv (id, name), then run the query below to get the amount per customer name. Rows with an empty amount are NULL and drop out of the sum.

SELECT c.name, SUM(o.amount) AS total
FROM orders o JOIN customers c ON c.id = o.customer_id
GROUP BY c.name ORDER BY c.name;

With the sample files, Kim comes out at 1500.5 and Lee at 200. The same approach gives monthly totals with strftime('%Y-%m', ordered_at).

It is SQLite syntax

This tool runs SQLite, not DuckDB. Work with dates through date(), strftime() and julianday(); DuckDB and PostgreSQL features such as DATE_TRUNC, ILIKE and QUALIFY raise an error. Integer division is integer: 7 / 2 is 3, so write 7 * 1.0 / 2 when you need decimals. String comparison is case-sensitive (only LIKE ignores ASCII case); single quotes are for values and double quotes for names. Write statements (CREATE TABLE … AS SELECT, UPDATE) run too, but they change only the in-memory tables, never your files.

Limits

  • Up to 500 MB of files and 2,000,000 rows in total, and up to 500 columns per table. Everything sits in browser memory, so smaller files are safer on phones.
  • The result grid holds the first 10,000 rows. If the script only reads, exports re-run the query and include everything.
  • A query that runs past 30 seconds is stopped and the tables are rebuilt from the files you loaded. Tables created with SQL and values changed with UPDATE are lost.
  • Legacy .xls and password-protected Excel files cannot be opened; save them as .xlsx first. Nested Parquet columns (lists, structs) are stored as JSON text, and integers beyond 2^53 are stored as text to keep every digit.

To open a database file instead, use the SQLite Viewer; to tidy a query, the SQL Formatter; to clean up a table without SQL, the Excel & CSV Workbench.

Your files are processed only in your browser and are never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.