I have a list of tables (1,2,3) and would like to join the tables, tables by table, to a list of feature classes (1X,2X,3X). So that table 1 combines with feature class 1X, table 2 with feature class 2X and so on. The first table of the correspondent workspace should combine with the first feature class of the correspondent workspace, the second with the second and so forth.
I think it is similar to this problem where a solution is provided but in arcpy which I am not yet into! (https://community.esri.com/t5/python-questions/join-multiple-tables-to-multiple-feature-classes-arcpy/td-p/181549/page/2) I experimented with lists, batch function and iterators but could not find a solution. The batch function seemed suitable, but it seems only to work with one list and the counterpart must be a single feature class/table as far as I could see. I will show pictures of what from my point of view might be the closest solution but isn't working anyways. I thought I might iterate through the tables and the feature classes (one iteration in a submodel).
Or will this model try to combine every table with every feature class in my workspaces?
Edit: I tried a solution in arcpy. I runned it in ArcMap 10.7 python console. So I think it is using Python 2.7. (this is why I changed the f' strings from the solution in the link above [only available from Pyhton 3?] to "%" for inline variable substitution).The script runs but joins all tables to the last feature class in the list:
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]
#Find Table and Feature from Lists with same Name and join them
for feature in featureList:
if feature == "%tableNum%":
inData = featureGDB + "%\feature%"
inField = "OBJECTID"
joinTable = tableGDB + "%\table%"
joinField = "OBJECTID"
arcpy.JoinField(inData, inField, joinTable, joinField)
The table names are "WP_20200723_001_dist" till "WP_20201010_005_dist". The feature class names are the same less the "_dist" anex: "WP_20200723_001" till "WP_20201010_005". Both lists have the same number of items.