[Qgis-developer] function similar to Excel VLOOKUP

DelazJ delazj at gmail.com
Thu Jul 30 05:34:21 PDT 2015


Hi,
I think combining getFeature and attribute functions should help u do that
in the field calculator, though I haven't used them on csv files.
Assuming col1 in your csv contains also the code you are looking for,
applying this expression on shapefile "col 6" in QGIS field calculator may
do the job:
attribute (getFeature ('mycsvfile', 'mycsv_col1', "myshape_col1"), 'col2')

Regards,
DelazJ

2015-07-30 13:06 GMT+02:00 Zoltan Szecsei <zoltans at geograph.co.za>:

> 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
> ===========================================
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150730/ad6c270c/attachment.html>


More information about the Qgis-developer mailing list