1

I have a CSV file with four columns. The first column is text, and the succeeding columns are percentages. I have set up a csvt file with "String", "Integer", "Integer", "Integer"

When I import the file into QGIS as a delimited text layer, QGIS strips out all the percentages. They come in as null values.

LGA_NAME    Non-Indigenous  Aboriginal  Torres Strait Islander
Albury (C)  93% 2%  0%
Armidale Dumaresq (A)   88% 6%  0%
Ashfield (A)    93% 1%  0%
Auburn (C)  93% 1%  0%
Ballina (A) 93% 3%  0%
Balranald (A)   87% 6%  0%
Bankstown (C)   94% 1%  0%
Bathurst Regional (A)   91% 4%  0%
Bega Valley (A) 93% 3%  0%
Bellingen (A)   94% 3%  0%
Berrigan (A)    94% 2%  0%

The three headings are Non-Indigenous, Aboriginal, Torres Strait Islander.

  • Can you post a (subset) of your data so that we can test it? – Phil Jul 15 '16 at 9:53
  • Sure. Here is some of the data. – Phillip Money Jul 15 '16 at 9:54
  • 2
    So your data is line Name, 10%, 20%, 30%? 10% is not an integer it has a % sign in it, it is a string. So you would bring them into QGIS and convert them into integers. – HeikkiVesanto Jul 15 '16 at 9:56
  • Vesanto, I have also tried bringing the percentages in as numbers such as 0.93. I get the same result. How do I convert a percentage to a number in QGIS? – Phillip Money Jul 15 '16 at 9:58
  • I was able to import this without problem into QGIS (2.14.4 Ubuntu). Before I exported from Libreoffice I converted the percentages to numerical values. Perhaps Excel has a similar option? – Phil Jul 15 '16 at 10:09
2

Your numbers still contain the "%" symbol. If you want them to be recognized as numbers then loose the "%". i.e.:

LGA_NAME;Non-Indigenous;Aboriginal;Torres Strait Islander 
Albury (C);0.93;0.02;0.0
Armidale Dumaresq (A);0.88;0.06;0.00

Also be sure you are choosing the semicolon ";" as the "Custom delimiter" when you do the import.

Imported table

  • I am importing the file, thus: I have taken out the percentage symbol and converted them numbers. It still doesn't work. – Phillip Money Jul 15 '16 at 12:13
  • I could show you in a picture, but I don't know how to paste pictures into here. – Phillip Money Jul 15 '16 at 12:14
1

For what it's worth, I entered your data into Libreoffice like this:

raw data with percentages

I don't think I've got the data right, but that doesn't matter; it's just to illustrate the method.

From here in Libreoffice I selected the percentage data and converted to numeric:

numeric data

Excel has a similar option to change how the data is stored. Note the percentage symbols have been removed when converted to numeric. If the percentage symbols do not disappear when you convert to numeric it suggests these are manually typed in and you therefore have a string. If this is the case you need to manually remove the percentage symbols with a find and replace.

Once exported to some delimited format (csv, semi-colon separated, tsv, whatever you want) I was able to import into QGIS with Add Delimited Text Layer:

qgis import

The only option I've modified is 'No geometry (attribute only table)'.

0

If you want to use a CSVT file, you must use Add Vector layer. Delimited text does a datatype guess on its own.

See Why the table fields imported from a .csv file have a length of zero? and Why are some columns not recognized as numeric even though I have a CSVT? about that.

  • Thanks everyone for the help. I am working through this. – Phillip Money Jul 18 '16 at 1:49

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.