I would like to request this improvement to the shell .import command.  (Wish 
list, I guess.)

Current .import behavior is that when the imported table does not exist, it 
will be created using the first row from the data file as column names for the 
new table.

This is great but it has one problem:

Example use case: Loading phone call logs.  Each month a new file with just 
that month?s activity needs to be inserted.  So, old data has to remain as is, 
and new data added to the table.  The format of the file is always the same: 
header row followed by data rows.

Once the initial table is created by the first .import, every subsequent time 
.import will add the header row again and again as data.

My suggestion to avoid this is to behave like so, instead:

1. If the table does not exist, the same as current behavior: Create table 
using first row for column names.
2. If the table exists, and the first row matches the column names, skip the 
first row, and continue inserting the rest of the rows.
3. If the table exists, and the first row does not match the column names, 
treat as data, and insert into table.  (This takes care if the file has no 
longer header row, or manually edited out.)

Is this possible?

It?s a real nuisance to have to edit out the headers every time, especially 
when the files are very large and they do not load fast (or at all) into a text 
editor.  Plus, it?s semi-automatic.
(I know I could write a Lua/Python script to do this filtering but I think it 
would be simpler and more immediate if the SQLite shell could take care of it 
directly.)

Thank you.

Reply via email to