I have two attribute tables, 1 from a shapefile layer (left) and 1 from a csv layer (right). I would like to find values in the first column ("KEY" column in shapefile layer) that appears in the second column ("KEY_ID" column in the csv table layer). I will likely have them selected and exported as a separate csv file, containing only those IDs that appear in both columns.

enter image description here

1 Answer 1


You can achieve this by joining the shapefile with the CSV file based on the common fields between them (KEY field and KEY_ID).

To do this, add both shapefile and CSV files as layers to the table of Contents using Add vector files, then right-click the shapefile -> Properties -> Join -> Add join (green plus at bottom left) -> Select the CSV file as Join Layer, KEY_ID as Join Field, and KEY field as Target field from the shapefile.

Now the field that are joined are the identical KEYs that you can use for further analysis.

  • Good one, i tried this before but the problem is i only want the filtered csv, to use the resultant data in the csv for further analysis. Problem is both the shapefile and the csv has over 100 columns/attributes, and doing this merge will result in a large file of which i have to then manually delete those columns from the original shapefiles. This is typically ok, but i have many of these shapefile + csv pairs to do this, and also some column data tend to turn out a little awry this way. Is there any other way to just filter/find the fields in the csv? thanks!
    – abigfatcat
    Commented Sep 7, 2019 at 15:57
  • If you have too many columns and you are interested in one or two, you may need to do some cleaning of the CSV file before joining. It may be necessary to use pyqgis to automate the process of cleaning and merging. Currently I cannot think of any easier way than the one suggested.
    – ahmadhanb
    Commented Sep 7, 2019 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.