Try creating a script file something like(Psuedo code):
.separator ","
CREATE TEMP TABLE dummy (value);
.import file1.csv dummy
INSERT INTO TEST (filename,number) (SELECT 'file1.csv', value FROM dummy;
delete from dummy;
.import file2.csv dummy
INSERT INTO TEST (filename,number) (SELECT 'file2.csv', value FROM dummy;
DROP TABLE dummy;

On 7/2/2010 1:42 PM, Peng Yu wrote:
> Hi,
>
> Suppose that I have a number of files, each file has some numbers in
> it (by line). I want to load the content of each file and the
> associated filename into the following table.
>
> create table test (id integer primary key, filename text,  number integer);
>
> For example, if file 'a' has number 1,2,3. Basically, I want to do
>
> insert into test (filename, number) values('a',1);
> insert into test (filename, number) values('a',2);
> insert into test (filename, number) values('a',3);
>
> I could convert each file with an additional field that has the
> filename, and then .import it. But I wondering if there is a syntax in
> sql that can allow me to add a field directly. I don't find such a way
> and I just want to double check.
>
>    
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to