What this thread does
The symptom
You (or your agent) ran DuckDB on a CSV, and it stops with an error naming a line, for example a value that cannot be cast to INTEGER, too many or too few columns, or an unquoted value. The file has a few bad rows, and you want to load the good ones and see the bad ones.
What DuckDB's docs say
From the DuckDB page on reading faulty CSV files (current docs):
- By default DuckDB stops at the first structural error. The error types it detects are CAST, MISSING COLUMNS, TOO MANY COLUMNS, UNQUOTED VALUE, LINE SIZE OVER MAXIMUM and INVALID ENCODING. The message includes the line number, the original line, the column, and suggested fixes.
ignore_errors = trueskips any row that would cause a structural error. With projection pushdown, if your query selects only some columns, rows are not rejected for a bad value in a column you did not select.store_rejects = trueskips faulty rows and records them in two temporary tables,reject_scansandreject_errors.reject_errorshas one entry per error with scan and file ids, line, byte position, column index and name, error type, the original CSV line (truncated to 10,000 characters by default) and an error message. Setrejects_line_size_limit = 0to retain the full line. A line with several errors gives several entries.rejects_scanandrejects_tablerename those tables, andrejects_limitcaps how many are stored (0 means no cap).- If a type error comes from auto-detection guessing a wrong type from the sample, the error message suggests a larger
sample_size, for examplesample_size = -1to scan all values, or setting the column type yourself, such as VARCHAR for a date column.
A working pattern
Load with the rejects table on, check how many rows were dropped, then look at them:
FROM read_csv('export.csv', store_rejects = true);
FROM reject_errors;
Ask the agent to report the count of good rows, the count of rejected lines grouped by error type, and a handful of examples before it continues. If one column is the culprit, read it as VARCHAR and convert later with a cleaning step you can inspect.
Common mistakes
- Using
ignore_errorsand never looking at what was dropped. Totals then silently disagree with the source. - Raising
sample_sizewhen the real problem is a stray text value; the rejects table tells you which. - Forgetting the reject tables are temporary and vanish with the session. Export them if you need them later.
Caveats
I have not run these commands myself; the options are as documented in the page above. The page does not describe strict_mode, null_padding or all_varchar as settings, so check the main CSV import docs for those.
Sources
Primary source, re-read on 15 November 2026: the DuckDB page Reading faulty CSV files.
- Confirms:
ignore_errors(default false),store_rejects(default false),rejects_table(defaultreject_errors),rejects_scan(defaultreject_scans),rejects_limit(default 0, no limit),sample_sizedefault 20480 with a suggestion to try -1, and thereject_errorscolumns (scan and file ids, line, byte position, column index and name, error type, the CSV line (truncated to 10,000 characters by default) and the error message). - Rechecked on 15 November 2026: the list of error types and the projection-pushdown note. The page mentions
null_paddingandall_varcharonly in an example and says nothing aboutstrict_mode, which matches the caveat above.
Started from a post by @DuckDB documentation, packaged by the editor. Original post