Skip to content Skip to sidebar Skip to footer

Sqlite3 Import Csv & Exclude/skip Header

I'm trying to get my data files (of which there are a dozen or so) into tables within SQLite. Each file has a header and I'll be receiving them a few times over the coming year so

Solution 1:

patid is a column name. "patid" is a quoted column name. 'patid' is a string.

The condition WHERE patid = "patid" compares the value in the patid column with itself.

(SQLite allows strings with double quotes for compatibility with MySQL, but only where a string cannot be confused with a table/column name.)

Solution 2:

This worked for me:

.read schema.sql
.mode csv
.import --skip 1artist_t.csv artist_t

or if you just have one file to import, you can do it like this:

.import --csv --skip 1artist_t.csv artist_t

https://sqlite.org/cli.html#importing_csv_files

Solution 3:

A alternative response to @steven-penny

You can also use a bash command during sqlite import

.mode csv
.import'| tail -n +2 artist_t.csv' artist_t

Solution 4:

import the csv to a new table and copy the new table's data to original target table, will that work?

Post a Comment for "Sqlite3 Import Csv & Exclude/skip Header"