-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Hans-Martin
Bundeshund
Sent: Friday, March 06, 2009 6:23 AM
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
=============================
Hi Hans,

The sqlite command-line utility program does not have code in it to
handle quoted strings containing the field separator (comma, in your
case), nor does it expect the multi-line data.

If you can have your data written as tab-separated (and without embedded
CR/LF) you may have better luck.

Alternatively -- for the new utility you wrote, did you surround your
import within a single transaction?   If not, then every row becomes a
separate transaction, and one would expect performance to suffer
drastically.

Regards,
   Donald

      
_______________________________________________
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

Reply via email to