Sunday, 13 January 2019

qgis - Why are some columns not recognized as numeric even though I have a CSVT?



I have problems importing a .csv file.


Some Values of the file are not supposed to be formated in text style, but in number style, thus i created an additional .csvt file like explained here.


Both files with exactly the same name and the same location are created. The number of columns is the same and I add the .csv file with the "Add Delimited Text Layer" tool. Nevertheless I am not able to choose any columns for a graduated symbology.


My .csv file includes 12 rows, of which the 5th, 11th, and 12th column consist numbers. My .csvt file therefore looks like that:


"String","String","String","String","Integer","String","String","String","String","String","Integer","Integer"


I tried to create it with the standard editor from Windows and Notepad++. Are there any common mistakes done by newbies, like I am one? Thank you for your help!



Answer



The "Add delimited text layer" tool does not interpret the CSVT. Only "add vector layer" needs a CSVT. Basically, "add delimited text layer" tries to make a best guess and it usually does very well recognizing numeric values. One of the reasons to use "add vector layer" is that "add delimited text layer" requires a geometry column.


Does your CSV contain a geometry or x and y columns? Then use "add delimited text layer".


If your CSV does not contain any coordinates/geometry, use "add vector layer".



As to why the numeric values are not recognized by "add delimited text layer", please post your CSV or at least a sample (first few lines). If even one line in the file contains a text in the "numeric" column, the tools will default back to String.


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...