I'm using QSpatialite only. I don't have spatialite-gui, neither the shell.
I want to import multiple TXT/CSV at one time, but I found nothing on the internet.
How is it possible to do this?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
You'll definitely want to install the spatialite shell program and run the imports in a loop. You can write a simple sql/sqlite command file (let's call it imports.sql) with lines like:
.separator ','; .import first.csv first .import second.csv second .import third.csv third ....
spatialite -init imports.sql csvfiles.sqlite
=== Edit ===
Here are some more details. I tried on a small set of simple csv files, and it seems to work: First a loop (run on linux) to collect all the files into one "import.sql" command file.
echo ".mode csv" >> imports.sql; for f in *.csv; do t=`basename $f .csv`; \ echo "CREATE TABLE $t (id INTEGER, name text, label text, x double, y double);" >> imports.sql; \ echo ".import $f $t" >> imports.sql; done
Now I ran:
spatialite -init imports.sql test.sqlite
Tables were created and the data rows imported. You have to make sure your CSV files are identical in structure, and "clean" i.e. no extraneous commas, text should be quoted, etc. And of course you will need design the above "CREATE TABLE statement to match the columns in the CSV files.