1

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

asked Aug 9, 2013 at 5:35

1 Answer 1

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.

answered Aug 9, 2013 at 14:11
1
  • 1
    Creating a csvt file containing : "Integer(3)","String(10)","Real(10.7)" worked. Commented Aug 11, 2013 at 22:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.