Here is an easy way to reproduce the symptom.  Given the following file
as input for the .import command:

---csvtest.csv---
"1","wilson, ron"
"2","momma, your"
-----------------

Here is the sqlite output:

SQLite version 3.5.9
Enter ".help" for instructions
sqlite> create table names (id integer, name);
sqlite> .mode csv
sqlite> .import csvtest.csv names
csvtest.csv line 1: expected 2 columns of data but found 3
sqlite> .quit

Clearly it is parsing the comma in the name column as a record
delimiter.  Is there a mode that causes the .import command to honor
quoted entries?

RW

sqlite>select level from sqlGuruOMeter where name="Ron Wilson";
2

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Wilson, Ron P
Sent: Tuesday, August 19, 2008 4:49 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] .import with .separator and quoted strings

I'm trying to import a table using the command line tool.

 

sqlite> .separator ,

sqlite> .import export.csv library

export.csv line 1: expected 53 columns of data but found 77

 

sqlite> .mode csv

sqlite> .import export.csv library

export.csv line 1: expected 53 columns of data but found 77

 

All entries are quoted strings, but some of them have commas within the
strings.  It appears that SQLite is ignoring the string quoting and
taking all commas literally.  Is this intended?  The same import works
fine in Excel with 53 columns resulting.  I have also tried tab
delimited and apparently some of the strings in this dataset also
contain tabs.

 

sqlite> .mode tabs

sqlite> .import export.txt library

export.txt line 162: expected 53 columns of data but found 55

 

I don't control the data source, and I would really like to avoid
pre-munging the data.

 

RW

 

sqlite>select level from sqlGuruOMeter where name="Ron Wilson";
2

 

_______________________________________________
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