Skip to main content

Module dialect

Module dialect 

Source
Expand description

What a CSV file’s punctuation is, and working it out from the bytes.

A CSV file does not say how it is written. The delimiter, the quote, the escape and whether the first line is a header are all conventions, and a reader that demands to be told them is a reader every loader script has to be rewritten for. DuckDB sniffs, so this sniffs, and every rule here was read off duckdb v1.4.1’s sniff_csv rather than reasoned about.

The candidates are DuckDB’s: comma, pipe, semicolon and tab for the delimiter, and the double quote for the quote and the escape. A file with no quote character in it is reported as having no quote at all rather than as having the default one, which is visible in sniff_csv and is reproduced because the same field is printed back in an error message.

Structs§

Dialect
How a CSV file is punctuated.
Given
What the caller said about how the file is written, where the sniffer would otherwise decide.

Constants§

DELIMITERS
The delimiters tried, in the order they are tried.

Functions§

delimiter
Which delimiter splits sample into the most columns, consistently.
quote
Whether the file uses a quote character at all, and which one.