Thanks Monte for your response.
I am still pretty new to SQlite, but it looks very similar to what Simon suggested. I think it would work just as well. From my perspective the ideal way to do this would be to specify the columns names the following data in the file is to load into. Then have an option in the .import function to say that the 1st line in the file defines the column names. -Chris ----- Original Message ----- From: "Monte Milanuk" <memila...@gmail.com> To: sqlite-users@sqlite.org Sent: Friday, July 9, 2010 10:11:41 AM Subject: Re: [sqlite] importing data from file with 3 colums to table with 4 columns Just because I was bored ;) I decided to take a stab at this one as well (following Simon's excellent guidance). I had thought because of what it says in the FAQ here: http://sqlite.org/faq.html#q1 that it should be possible to import the values directly into the final table and have sqlite auto-populate the primary key field as it went. If it is possible, I haven't found any good examples of *how*. As it is... I came up with the following import-csv.sql file for importing your CSV data: CREATE TABLE t1(ID integer primary key autoincrement, Name varchar(40), Category varchar(40), Recommendation varchar(40)); CREATE TABLE t2(a, b, c); .separator "|" .import data.csv t2 INSERT INTO t1(Name, Category, Recommendation) SELECT * FROM t2; DROP TABLE t2; .headers on .mode column .width 5 20 9 15 SELECT * FROM t1; After that... running the following command should net the resulting output: E:\sqlite>sqlite3 temp.db ".read import-csv.sql" ID Name Category Recommendation ----- -------------------- --------- --------------- 1 Barracuda seafood No 2 Catfish seafood No 3 Caviar seafood No 4 Conch seafood No 5 Herring(pickled) seafood No 6 Lox(smoked salmon) seafood No 7 Octopus seafood No E:\sqlite> Not sure if that was exactly what the OP was after, but it kept me entertained ;) _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users