Hi Hans-Martin

Try changing the double-quotes to single-quotes in your string data. Bear in 
mind that if you want a single-quote to appear in a string, it must be escaped 
with another single-quote i.e. ''. Excel should be able to automate this for 
you.

Cheers,
Dave.


-----Original Message-----
From: Hans-Martin Bundeshund [mailto:bundesh...@yahoo.de] 
Sent: 06 March 2009 03:23
To: sqlite-users@sqlite.org
Subject: [sqlite] import a CSV-File


Hello to the List!

I started using SQLite (3.6.11) under WindowsXP and get confused using the 
import-function. The import runs well with most lines, but i get an error when 
it comes to following cases:


Case 1, the ',' between a string:

"Text of field1","Text of field2, not for field1"<CR><LF>

after trying to import this, i get an error saying the CSV-File has 3 Fields. 
So does strings containing a ',' are handled wrong via SQLite, or do i miss 
something?




Case 2, maybe a mistake of IBM's DB2 running on an iSeries:

"Text of field1","Text of field2:<CR><LF>Not for field2!"<CR><LF>

well, you guess what will happens here. The field2 has a <CR><LF> what is 
exported as it is, not converted to something like "\n" or so. And for SQLite 
the line ends here. (I wonder that the iSeries does that, because the <CR><LF> 
is a special character for the CSV-file, not to be used as value in a field, 
but thats what i get...)


Both errors can be solved by watching the leading and ending '"'-characters. If 
',' or <CR><LF> is between two quotes, its not a CSV-code, its only text to 
write to a field.


So any ideas for solving this out? I wrote a litle C++ .Net-application 
scanning a CSV in the right way and fill a SQLite-DB via ODBC. But that need a 
very long time (about 1 hour) to insert 40000 rows to it  :(

regards,

HMB


      

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to