> -----Original Message----- > From: sqlite-users-boun...@sqlite.org > [mailto:sqlite-users-boun...@sqlite.org] > On Behalf Of RSmith > Sent: Wednesday, June 26, 2013 10:21 AM > To: General Discussion of SQLite Database > Subject: Re: [sqlite] sqlite3: .import command handles quotation incorrectly > All --
IMO, CSV Files generally suck. I often had to resort to an external CSV-File preprocessor to clean up various Broken CSV File Formats. But it took two-steps and a temp file: 1. mypreprocessor Broken.CSV > Cleaned.TXT 2. echo " .import Cleaned.TXT TargetTable ; .exit ;" |sqlite3 -separator '|' MyDataBase.db One thing that I've found to be handy without breaking sqlite3 or adding too much code to shell.c was a new sqlite3 dot-command: .pimport ... the .pimport command imports data from a pipe instead of a text file. Syntax example: .pimport TargetTable command arg [arg [arg] ...] ; Here's a sample session. $ ./sqlite3 foo.db SQLite version 3.7.17 2013-05-20 00:56:22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table foo( col1 int, col2 varchar(255) ) ; sqlite> .pimport foo gawk 'BEGIN { for( i = 1 ; i <= 10 ; i ++ ){ print i "|" "this is string " i } ; exit 0 }' ; sqlite> select * from foo ; 1|this is string 1 2|this is string 2 3|this is string 3 4|this is string 4 5|this is string 5 6|this is string 6 7|this is string 7 8|this is string 8 9|this is string 9 10|this is string 10 sqlite> .exit Attached is a patch for shell.c please use it if it's helpful. While there's code for WIN32, I've never needed it nor tested it ... -- kjh
_______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users