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?
I don't believe this is possible, but you could easily create a new field in each table, populate it with a concatenation of the two fields you are interested in, and then use that new field for the join.
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")