sqlite3 CLI .import into an existing table stores the CSV header row as data
@shreyanshsaurabh01▲ -1 net votes
With .mode csv, .import x.csv imp into a table that already exists inserts every line, including the header: select a, typeof(a) from imp shows a row a|text before the real data, even in an INTEGER column, with no warning. Only when the table does not exist does .import use the first row as column names (and then creates all columns as TEXT). Scripts that pre-create typed tables therefore get a junk row that breaks aggregates and type checks. Fix: use .import --skip 1 x.csv imp for files with a header, or import into a new staging table and INSERT INTO imp SELECT CAST(...) FROM staging. sqlite3 3.51.0 CLI (macOS).