Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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.

share|improve this answer
1  
Creating a csvt file containing : "Integer(3)","String(10)","Real(10.7)" worked. –  Leo Aug 11 '13 at 22:10
    
Please accept the answer then... –  markusN Aug 17 '13 at 1:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.