3

I'm trying to add a table in QGIS but I cannot define the datatype of my fields, as when imported they get automatically "read" as string.

I have tried to add a csvt file, by filling a .txt with the datatype of each column/field, as follows:

"String(3)",String(20)",Integer(5)","Real(20.2)","Real(20.2)","Real(20.2)","Real(20.2)" 

I saved the file with the same name of the CSV (but followed by the new extensions) and saved it in the same folder containing the original CSV file, as follows:

file_name.csv

file_name.csvt

I have tried to import the CSV by "Add delimited text layer", "Add vector layer", and browsing and dragging the file directly in QGIS. The imported file's fields are still all strings.

Not sure if this is relevant but my computer doesn't recognise the csvt file format and still reads it as a .txt file.

What am I doing wrong?

3
  • 1
    Would be helpful to see a sample of your data (update the question to include a screenshot). Also check if you really have only numbers in your Real and Integer fields, no other characters. – Babel Dec 24 '20 at 15:50
  • 2
    You've got some missing quotation marks in your CSVT format - specifically there's no opening quote on the second and third item. – Spacedman Dec 24 '20 at 16:12
  • Yeah sorry guys, it was a bad copy&paste, but it was actually written correctly in the .txt file but still not working – Alessio Bulckaen Dec 25 '20 at 19:30
1

Seems the problem was related to my computer not being able to read a csvt file.

I downloaded a .csvt file from a public github space, then edited with my datatype inputs and now it works fine on QGIS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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