<div dir="ltr"><div><div>Hi,<br></div>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.<br></div><div>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:<br></div><div>attribute (getFeature ('mycsvfile', 'mycsv_col1', "myshape_col1"), 'col2')<br></div><div><br></div><div>Regards,<br></div><div>DelazJ <br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-07-30 13:06 GMT+02:00 Zoltan Szecsei <span dir="ltr"><<a href="mailto:zoltans@geograph.co.za" target="_blank">zoltans@geograph.co.za</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
How could I implement something like vlookup in QGIS?<br>
<br>
I have a shapefile with 2000 polygons and column 1 of its attribute table has a code value.<br>
<br>
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.<br>
This returned value must then be placed into a new column (say column 6) on the shapefile attribute table.<br>
I could pre-add the new column to this shapefile, and then run the vlookup equivalent too, of course.<br>
<br>
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.<br>
<br>
Once back in QGIS the attributes ended up being linked to the wrong polygons (probably because I sorted the DBF file outside of QGIS).<br>
<br>
Thanks in advance,<br>
Zoltan<br>
<br>
<br>
-- <br>
<br>
===========================================<br>
Zoltan Szecsei PrGISc [PGP0031]<br>
Geograph (Pty) Ltd.<br>
GIS and Photogrammetric Services<br>
<br>
P.O. Box 7, Muizenberg 7950, South Africa.<br>
<br>
Mobile: <a href="tel:%2B27-83-6004028" value="+27836004028" target="_blank">+27-83-6004028</a><br>
Fax:    <a href="tel:%2B27-86-6115323" value="+27866115323" target="_blank">+27-86-6115323</a>     <a href="http://www.geograph.co.za" rel="noreferrer" target="_blank">www.geograph.co.za</a><br>
===========================================<br>
<br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br></div></div>