Am 6.8.05 um 09:06 schrieb Joe Noon:

You can use a system call to execute a command like the following;

sqlite3 -separator , test.db ".import test.csv sometable"



That is exactly what I needed! Thanks a ton.

Joe Noon



My issue now is that the csv may or may not have all of the columns
that my table has.  For instance, my table has 12 columns, but the csv
has only 2 or 3 columns worth of data in some instances.  This is
possibly due to a mal-formatted csv to begin with, but its all I have
to work with here.  sqlite obviouslly errors out saying the file only
has x records but the table contains 12.  Is there any way to force
the import no matter what exists?

For some background on what Im trying to do.. basically Im just trying
to get a csv file into the db so i can use SQL to search by the first
column.  The column names are just a,b,c etc.  Data integrity is a
non-issue here.


You could preprocess the csv file (e.g. using awk or similar tools) and generate a file that contains only the first column if that's all you're interested in. With this file and a table that only contains a single column, the import should succeed.

</jum>

Reply via email to