On 12 Dec 2009, at 5:36pm, FrankLane wrote: > I have a tab-delimited file that contains all my data, and I would like to > write a php program which displays on a web page the results of various > sqlite operations on a table created from that data. I still do not > understand how to load the file into an sqlite table that is accessible by > the php program. You gave two options A) import using command line tool and > B) use insert commands. I think insert commands are out of the question, > since my tab-delimited file contains thousands of records,
No, it's just programming. You write a loop in your PHP code. For example: 1. read your entire file into a string variable 2. split the string variable into an array of strings, one per line of the file 3. loop around for each element of the array 4. look at that line of the array and separate the values for each field 5. create an INSERT command 6. feed that INSERT command to the correct database function 7. end of loop Quite a simple program. You could probably do it in 20 lines of PHP. These might help: http://php.net/manual/en/function.readfile.php http://php.net/manual/en/function.split.php http://php.net/manual/en/control-structures.foreach.php http://php.net/manual/en/language.operators.string.php > so that means I > go with A). You say to use the command line tool - Is that sqlite3? Yes. But you would use this solution only if you wanted to import the data by typing. If you are just importing the text file once then it is a good solution. If you need to import a text file many times you need to write a program to do it. > or is > there a way in the php program to issue command lines? No. The '.import' and everything like it are purely for the command-line tool. They are not commands you can give to SQLite. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users