Hello All,

Wouldn't it make sense to write a program that reads it in, one line
at a time, splits and inserts the data into the proper tables? Even
creating the table on the fly? That's what I'd do, a little command
line utility.

It's basically the "convert to SQL" technique you suggest where the
SQL conversion's done programatically in the utility.

Tuesday, December 6, 2005, 11:50:50 PM, you wrote:

RLC> I create an SQL file that has contents like this:

RLC> [EMAIL PROTECTED] elections]$ cat insert_precinct.sql
RLC> BEGIN TRANSACTION;
RLC> INSERT INTO "precinct" VALUES(1, 'Community Center 15 Crescent Road', 3,
RLC> 'Greenbelt', 'Maryland', 0);
RLC> INSERT INTO "precinct" VALUES(2, 'Police Station 550 Crescent Road', 6,
RLC> 'Greenbelt', 'Maryland', 0);
RLC> INSERT INTO "precinct" VALUES(3, 'Springhill Lake Recreation Center 6111
RLC> Cherrywood Lane', 8, 'Greenbelt', 'Maryland', 0);
RLC> COMMIT;

RLC> Then I fire up sqlite3 on the command line, and issue

RLC> .read insert_precinct.sql

RLC> I realize this will probably make you unhappy because it means editing
RLC> your CSV file so that each line is transformed into an sql statement.
RLC> This can be done most easily with sed (if you are a Linux or Unix
RLC> person), but you need to know sed commands and you need to be willing to
RLC> patiently experiment until the sed script applies exactly the right edits.

RLC> Bob Cochran


RLC> ronggui wong wrote:

>>I have a very large CSV file with 10000 rows and 100 columns.and the
>>file looks like the following:
>>"a","b","c","d",
>>"1","2","1","3" ,
>>"3","2","2","1",
>>......
>>
>>If I use .import,It seems I have to set the variable names manually .
>>Is there any way to import the whole data file into SQLite quickly?
>>Thank you!
>>
>>ronggui
>>
>>
>>  
>>




-- 
Best regards,
 Teg                            mailto:[EMAIL PROTECTED]

Reply via email to