I have a 15 shapefiles for the years 2001-2015 that are named as so...


and I have one csv file that contains a field named 'year' that looks like this:

   pesticide  year  state  county   low  high
   THIAMETHOXAM  2001     38       5   0.5   0.5
   THIAMETHOXAM  2001     38      17   0.5   0.5
   THIAMETHOXAM  2001     38      21   5.6   5.6
   THIAMETHOXAM  2001     38      27   1.7   1.7
   THIAMETHOXAM  2001     38      29  37.6  37.6

I want to join the data for each year corresponding to its shapefile for each year. So when the 'state' field in the csv == 2001, I want join that subset of data to the 'state_2001.shp' and do so for each year. I could easily subset the data 15 times and do 15 joins, but that's not why I'm learning python!

I am assuming I would do an if statement and the joinfieldmanagement tool, but I don't know how to incorporate this into arcpy. Any advice for getting started?

closed as off-topic by PolyGeo Nov 3 '16 at 19:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • If you are joining the table to the shapefile that would be a one to many join which isn't an option (though you could do a relate). desktop.arcgis.com/en/arcmap/10.3/manage-data/tables/… – jbchurchill Nov 3 '16 at 14:53
  • It's not a one to many join, it is a one to one join. But the csv file is split according to year and then applied to the corresponding shapefile – dand Nov 3 '16 at 14:54
  • 1
    You should specify that in your question. I assumed you'd be joining based on the year field. The question could be further improved by including a python snippet showing how you'd go about splitting up the single csv file? – jbchurchill Nov 3 '16 at 16:01

You can use Join and Relate utility available on the Feature layer and csv when added into ArcMap.

Add the csv and feature class into ArcMap. Right Click on the Feature class and click on Join and Relate and then click on Join. Provide the csv with which to join and based on which column. Click ok.

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