Re: [Qgis-developer] function similar to Excel VLOOKUP - SOLVED
Awesome. Thank you. I added the extra column to the shapefile attributes, joined the shapefile to the CSV file, and then updated the new column in my shapefile using: attribute($currentfeature,'joinedcolumn') (NOTE: single quotes for field name) I'm sure I could have skipped the Join step and just used getfeature as suggested below, but I went the Join route anyway. Big thanks, Zoltan On 2015/07/30 14:34, DelazJ wrote: 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 zolt...@geograph.co.za mailto:zolt...@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 tel:%2B27-83-6004028 Fax: +27-86-6115323 tel:%2B27-86-6115323 www.geograph.co.za http://www.geograph.co.za === ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org mailto:Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer -- === 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@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] function similar to Excel VLOOKUP
How about a Join QGIS join Il 30/07/2015 13.06, Zoltan Szecsei ha scritto: 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 ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] function similar to Excel VLOOKUP
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 zolt...@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@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer