Loading CSV data
Put rows in data/<table>.csv and query them: each file becomes a table before your query runs.
Runs in Zerethon IDE · SQLite 3
Official SQL documentation ↗
main.sql
SELECT count(*) AS students,
avg(score) AS avg_score,
sum(score IS NULL) AS missing
FROM scores;
data/scores.csv
name,score
ada,90
alan,85
grace,
Result
| students | avg_score | missing |
|---|---|---|
| 3 | 87.5 | 1 |
data/scores.csv becomes the table scores.
- Every
data/*.csvfile becomes a table named after the file, aftersetup/has run. The first row names the columns. - If
setup/already created that table, the rows go into its columns (and its types apply); otherwise the table is created from the header. - Empty cells become NULL; whole numbers and decimals become numbers. Table and column names must be plain identifiers (letters, digits,
_). - At most 10,000 rows per file.