csv import without header row
From the cli page, it mentions that you can skip the header row by using the option --skip 1. However, I have not been able to make it work. Can you give an example or syntax of using that option?
(2) By Larry Brasfield (LarryBrasfield) on 2020-06-10 01:31:32 in reply to 1 [link] [source]
Study this session scrape:
sqlite> create table Pets (name text, species text); sqlite> insert into Pets values('Fido', 'dog'); sqlite> insert into Pets values('Fluffy', 'cat'); sqlite> insert into Pets values('Hiss', 'serpent'); sqlite> .mode csv sqlite> .header on sqlite> .once pets.csv sqlite> select * from Pets; sqlite> create table Beasts (name text, species text); sqlite> .import --csv --skip 1 pets.csv Beasts sqlite> select * from Beasts; name,species Fido,dog Fluffy,cat Hiss,serpent sqlite>
Unrelated to the original question:
I guess the “--csv” option is something new? Maybe it overrides the current mode? Where is that documented?
(6.1) By Larry Brasfield (LarryBrasfield) on 2020-06-13 18:16:01 edited from 6.0 in reply to 4 [source]
It should be documented in the CLI Shell docs, but is not. Because ".mode csv" had already been entered in the session I showed, that option was not necessary. But if you had not set the CSV mode before the import, that --csv option makes it happen during the import.
You can see its effect mentioned in the CLI shell by entering:
, (and scrolling back for the latter unless you have a huge monitor and a tiny font.)