
Fixing DuckDB CSV Type Detection That Guessed Wrong
When the DuckDB CSV sniffer picks the wrong type, override it by column, read as text and cast, or narrow the candidate types. A test file shows each guess.
Everything you need to level up your coding skills.

When the DuckDB CSV sniffer picks the wrong type, override it by column, read as text and cast, or narrow the candidate types. A test file shows each guess.

Read every CSV in a folder as one table in DuckDB with a glob, add the file name as a column, and handle files whose columns differ in count or order.

How the DuckDB CSV sniffer picks delimiter, header and types, how to read its verdict with sniff_csv, and what breaks when a bad value sits past the sample.

The read_csv options that solve real problems in DuckDB 2.0, each on a file that needs it, including the nullstr trap that replaces the empty default.

Install DuckDB, point it at a CSV and query it. Covers the file name shortcut, DESCRIBE, SUMMARIZE, reading from a pipe and writing CSV back out.

DuckDB runs SQL on a CSV file with no import, no schema and no server. See what it guesses, what that costs, where it fails, and how to make it strict.

SQLite .import stores every CSV value as text, so ORDER BY puts 10.25 before 2.75 and amount > 9 matches every row. See the cause and three ways to fix it.

One table per CSV file, with safe names and types inferred from the whole file. A short Python script that keeps ZIP codes as text and refuses ragged files.

A bash loop that imports monthly CSV files into one SQLite table, records which file each row came from, and refuses to load a file twice.

SQLite prints expected N columns but found M and loads the row anyway, with exit status zero. See each import message and what it did to the data.

Export a SQLite query to CSV with the shell, see exactly how 3.54 quotes values, writes NULL and ends lines, and learn which options change each.

Compile SQLite's CSV virtual table, query a file in place, and compare the cost with importing it and with DuckDB, including the typed schema surprises.
We send one email when a new article is published. No spam.