Hi @capitanf, I think you’re mis-reading the tutorial.
Since you’re working with sqlite directly via the command-line, importing a CSV is done by:
sqlite> .mode csv
sqlite> .import [path_to_file] [target_table]
[target_table] are the path to your CSV file and the table you want to import into, respectively.
The tutorial you’re following says this:
If the table already exists, the sqlite3 tool uses all the rows, including the first row, in the CSV file as the actual data to import. Therefore, you should delete the first row of the CSV file.
The following commands import the
city_without_header.csv file into the
sqlite> .mode csv
sqlite> .import c:/sqlite/city_no_header.csv cities
They are importing a different CSV file, called
city_no_header.csv - not running a different command called
The SQLite CLI reference also says the following:
There are two cases to consider: (1) Table “tab1” does not previously exist and (2) table “tab1” does already exist.
In the first case, when the table does not previously exist, the table is automatically created and the content of the first row of the input CSV file is used to determine the name of all the columns in the table. In other words, if the table does not previously exist, the first row of the CSV file is interpreted to be column names and the actual data starts on the second row of the CSV file.
For the second case, when the table already exists, every row of the CSV file, including the first row, is assumed to be actual content. If the CSV file contains an initial row of column labels, that row will be read as data and inserted into the table. To avoid this, make sure that table does not previously exist.
So, to summarise - if you want to import the CSV data into an existing table you need to remove the “header” line, if one exists. But then, you already knew that…