[Qgis-developer] function similar to Excel VLOOKUP

Zoltan Szecsei zoltans at geograph.co.za
Thu Jul 30 04:06:22 PDT 2015


Hi,
How could I implement something like vlookup in QGIS?

I have a shapefile with 2000 polygons and column 1 of its attribute 
table has a code value.

Using the code in this column 1, I need to look up which row of a CSV 
file has that code, and return column 2 of the CSV file.
This returned value must then be placed into a new column (say column 6) 
on the shapefile attribute table.
I could pre-add the new column to this shapefile, and then run the 
vlookup equivalent too, of course.

I tried this by opening the DBF file in Libreoffice calc, sorting the 
columns, adding the extra two columns of my lookup data, then ran 
vlookup and saved/closed the DBF file.

Once back in QGIS the attributes ended up being linked to the wrong 
polygons (probably because I sorted the DBF file outside of QGIS).

Thanks in advance,
Zoltan


-- 

===========================================
Zoltan Szecsei PrGISc [PGP0031]
Geograph (Pty) Ltd.
GIS and Photogrammetric Services

P.O. Box 7, Muizenberg 7950, South Africa.

Mobile: +27-83-6004028
Fax:    +27-86-6115323     www.geograph.co.za
===========================================



More information about the Qgis-developer mailing list