Sadly, the sqlite3 command line does not handle quoted fields when importing CSV very well at all. Commas inside quotes get treated as column separators, and newlines inside quotes get treated as row separators. I had this problem earlier this year and ended up using excel to create insert statements.
I don't recall this feature being fixed since then; correct me if I'm wrong. I haven't had time to fix it myself either, so I don't complain. RW Ron Wilson, Engineering Project Lead (o) 434.455.6453, (m) 434.851.1612, www.harris.com HARRIS CORPORATION | RF Communications Division assuredcommunications(tm) > -----Original Message----- > From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- > boun...@sqlite.org] On Behalf Of C. Mundi > Sent: Thursday, September 24, 2009 3:37 PM > To: sqlite-users@sqlite.org > Subject: [sqlite] Tedious CSV import question > > > Hi. I have scanned the list archives and Googled. I may have missed > something, but what I found was not sufficiently general or robust for > my > needs. > > Happily, sqlite has a very nice .output mode for CSV. It correctly > double-quotes fields when they contain a space or a comma, and it > correctly > 'escapes' double-quote literals as "". Great! I need to go the other > way. > > I don't see an inverse .import mode in sqlite to handle the completely > general CSV syntax. As anyone who has ever tried knows, parsing > compliant > CSV is a lot harder than writing compliant CSV. > > I'm hoping someone will (please) tell me I missed something in the > sqlite > docs. Otherwise, I guess I'll be using python's csv module to turn my > CSV > file into SQL insert statements. This is likely to be an infequent > task, > but it has to be done perfectly. So if someone knows of a command-line > tool > to turn CSV into SQL inserts, I would appreciate that too. > > Thanks, > Carlos > _______________________________________________ > 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