Hi!
I have a list of tables and a list of feature classes and I would like to join them, based on their names. The tables and feature classes I would like to join have the same name, but the tables hold and additional annex. I think my problem is similar to the one I found here already (https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes-arcpy/td-p/181549/page/2). I tried to copy the script and adapt it to my needs. The script is running without errors but I dont get the results. I would be very gratefull for suggestions. I would also appreciate a solution in model builder where I also could not find the way. Thank you!!
I use ArcMap 10.7 and run the script in the ArcMap python console.
import arcpy
#Define Geodatabase Path
featureGDB = r"C:\C_M2\arcpy\list\list_Events_SBA_wp.gdb"
tableGDB = r"C:\C_M2\arcpy\list\list_distance.gdb"
#Create Feature List Variable
arcpy.env.workspace = featureGDB
featureList = arcpy.ListFeatureClasses()
#Create Table List Variable
arcpy.env.workspace = tableGDB
tableList = arcpy.ListTables()
#Set table Names to featureList Names equivalent
for table in tableList:
tableNum = table [0:-5]
#Finde Table and Feature from Lists with same Name and join them
for feature in featureList:
if feature == "%tableNum%":
arcpy.JoinField_management(in_data="C:\\C_M2\\arcpy\\list\\list_Events_SBA_wp.gdb\\%WP_20200723_001%", in_field="OBJECTID", join_table="C:\\C_M2\\arcpy\\list\\list_distance.gdb\\%WP_20200723_001_dist%", join_field="OBJECTID", fields="DISTANCE")