arcpy: I would like to join a .xls table to a .shp table using two common fields, instead of one common field.
Is this possible in ArcGIS using python?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
One possible solution would be to create a concatenated field in both the spreadsheet and the feature class, then use the Excel to Table function to get your spreadsheet into a table, then use Add Join function to finish the join. Python would go a little something like this:
import arcpy env.workspace = "path to workspace" excel_file = r"path to file" input_fc = r"path to shapefile" output_table = r"path to output table" converted_table = arcpy.ExcelToTable_coversion(excel_file, output_table, "Sheet1") arcpy.MakeFeatureLayer_management(input_fc, "temp_layer") acrpy.AddJoin_management("temp_layer", "IN_FIELD", converted_table, "JOIN_FIELD", "KEEP_COMMON") arcpy.CopyFeatures_management("temp_layer, "path and name for output")