When importing a csv file on grass7, the numeric data is converted into a data of type string.
My csv looks like this :
id_core value
1 F1 83.0611472396
2 F2 98.8584345936
3 F3 102.0621496367
4 F4 95.4304750175
...
The command I use is :
db.in.ogr dsn=my_file.csv output=my_table
which displays the following message :
WARNING: Width for column field_1 set to 255 (was not specified by OGR),
some strings may be truncated!
WARNING: Width for column id_core set to 255 (was not specified by OGR), some
strings may be truncated!
WARNING: Width for column value set to 255 (was not specified by OGR), some
strings may be truncated!
WARNING: 50 features without geometry
Imported table <my_table> with 50 rows
And db.describe -c table=my_table
returns :
ncols: 3
nrows: 50
Column 1: field_1:TEXT:1000
Column 2: core:TEXT:1000
Column 3: stock:TEXT:1000
I tried to import the .csv without the header, or with only 2 decimal places on the values. I also tried to import an sqlite file (that I created with with libreoffice base) but the output is identical.
Does anyone has a suggestion for specifying that some fields are numeric?
Thanks
Léo
1 Answer 1
Check out the first example here: http://grass.osgeo.org/grass70/manuals/db.in.ogr.html
Limited type recognition can be done for Integer, Real, String, Date, Time and DateTime columns through a descriptive file with same name as the CSV file, but .csvt extension
Try to create a csvt file (with the same name as your csv file) according to the OGR documentation.
-
1Creating a csvt file containing : "Integer(3)","String(10)","Real(10.7)" worked.Leo– Leo2013年08月11日 22:10:05 +00:00Commented Aug 11, 2013 at 22:10