On Thu, Sep 24, 2009 at 12:37 PM, C. Mundi <cmu...@gmail.com> wrote: > > 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 >
Following up my own post: I just bit the bullet and did it. Python has an excellent csv module, capable of handling just about any dialect you're likely to encounter. I am so grateful I did not have to write a parser for CSV. In just a few lines I can read the csv right into sqlite. If anyone wants the code I will post it here if deemed appropriate. Carlos _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users