2

I need to import in a SQLITE database a CSV file that use both numbers than strings: here you a sample ..

col_1|col_2|col_3
10|text2|http://www.google.com

For the import I use Spatialite GUI because I've to manage also spatial data: all works fine in the import but when I try to select the data

select * from test;

enter image description here

How I've to structure my CSV file to store my "text2" string?

Cesare
  • 1,629
  • 9
  • 30
  • 72

2 Answers2

1

I've solved in a different manner ....

Enter in Sqlite and give these commands:

CREATE TABLE ps_details(
  col_1 TEXT,
  col_2 TEXT,
  col_3 TEXT
);
.mode csv
.separator |
.import test.csv test
.quit

You can save this in a file (es. test.txt) and then, in a second file named test.sh write

sqlite3 dbtest.sqlite < test.txt

save and change its permission (chmod 777), and then launch it form comand line

./test.sh

This will create a table test in your dbtest.sqlite getting data form test.csv file

Cesare
  • 1,629
  • 9
  • 30
  • 72
0

It looks like you defined the type of col_2 as REAL, where it should be TEXT.

The structure of your CSV look ok.

Disclaimer: I have never used Spatialite, this is just from looking at the information you provided.

zwippie
  • 15,050
  • 3
  • 39
  • 54
  • In the import I don't define the types of my columns ... It seems that it fix the type to REAL or something and not text as I suppose – Cesare Apr 10 '17 at 16:48
  • SQLite ignores column types, they are there just for compatibility. You can skip them as well. – Michał Leon May 20 '18 at 21:31