Hallo everybody
I'm trying to insert data from simple text file into sqlite database. I have 3 text files and i want to insert their contents into a database. The way how i do it, it works but the trouble is that the bigger the content is, more lines of code. This is how it looks like.
***********************************
file1.txt file2.txt file3.txt
item1-1 item2-1 item3-1
item1-2 item2-2 item3-2
item1-3 item2-3 item3-3
***********************************
***********************************
tbl_item1 = TextFile.ReadToTable("AutoPlay\\Docs\\1.txt");
tbl_item2 = TextFile.ReadToTable("AutoPlay\\Docs\\2.txt");
tbl_item3 = TextFile.ReadToTable("AutoPlay\\Docs\\3.txt");
db = SQLite.Open("AutoPlay\\Docs\\1.db");
SQLite.QueryToTable(db, "INSERT INTO collection (item1, item2, item3) VALUES ("..Enclose(tbl_item1[1])..", "..Enclose(tbl_item2[1])..", "..Enclose(tbl_item3[1])..")");
SQLite.QueryToTable(db, "INSERT INTO collection (item1, item2, item3) VALUES ("..Enclose(tbl_item1[2])..", "..Enclose(tbl_item2[2])..", "..Enclose(tbl_item3[2])..")");
SQLite.QueryToTable(db, "INSERT INTO collection (item1, item2, item3) VALUES ("..Enclose(tbl_item1[3])..", "..Enclose(tbl_item2[3])..", "..Enclose(tbl_item3[3])..")");
************************************
My question is ; is it possible to loop it somehow in order not to writte so much lines of code, some shorter way i mean. The content of each text file has to be inserted to the proper column.
I have tried this;
************************************
for i, v in tbl_item1 do
SQLite.QueryToTable(db, "INSERT INTO collection (item1) VALUES ("..Enclose(v)..")");
end
************************************
but the data is inserted in very ugly way. Where the data of one column ends there starts the data of the second column and so on.
Thank you

