Re: [sqlite] Improving CSV import

2019-05-07 Thread Shawn Wagner
Late follow up: > .import "tail -n +2 foo.csv |" mytable Found out today that this works (Though the pipe character has to be the first character, not the last) and apparently has for years, though I can't find it documented anywhere. On Thu, Mar 21, 2019 at 4:06 PM Shawn Wagner wrote: > Impor

Re: [sqlite] Improving CSV import

2019-03-21 Thread Roger Schlueter
Or, better yet .header n where n=0   <--no header n>0  <-- number of header lines If .header is not specified then it defaults to zero so breaking backwards is not a concern. On 3/21/2019 19:04, Shawn Wagner wrote: I thought about suggesting that, but I can see it breaking backwards com

Re: [sqlite] Improving CSV import

2019-03-21 Thread Shawn Wagner
I thought about suggesting that, but I can see it breaking backwards compatibility with existing scripts. I set .header on in my ~/.sqliterc for example, and have things that don't change it before importing csv files and would thus miss a row. (I also have a handy perl script that does all this s

Re: [sqlite] Improving CSV import

2019-03-21 Thread D Burgess
Agree with all that. > A way to skip a header row when the table exists would be useful. > How about > .header on/off ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

[sqlite] Improving CSV import

2019-03-21 Thread Shawn Wagner
Importing a CSV file in the command line shell has two different behaviors: if the table to import to doesn't exist, treat the first row of the file as a header with column names to use when creating the table. If the table does exist, treat all rows as data. A way to skip a header row when the ta