Wednesday, 8 April 2015

Changing CSV layer attribute value from text to number in QGIS?


I read in a CSV file for linking to a .shp file.


All the variables that are just numbers came in as text.


How do I change the text variables to numeric in QGIS?



Answer




I once had the same question. The answer is that you put a file in the same folder with the ending csvt. For example your file name is xyzdata.csv you add the file xyzdata.csvt


This one you can edit with editor for example. And in it you set the data type like this. "Integer","String","Integer","Integer","String","Real"


Integer is now the variable for the first column, string for the second and so on... Make sure the files are named identically.


Edit: See here too if needed: http://underdark.wordpress.com/2011/03/07/how-to-specify-data-types-of-csv-columns-for-use-in-qgis/


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...