I am trying to join feature classes in a list to tables in another list using a join field which is the same for all joins. In general terms, I want to join the first feature class in the list to the first dbf table in the list, the second feature class to the second table, an so forth. Here are two codes I have written and I get error messages for both.
import arcpy
>>> arcpy.env.workspace= c:/Users/Administrator/Documents/ArcGIS/NewFileGeodatabase.gdb"
#Trial 1
>>> fclist2= arcpy.ListFeatureClasses("D*", "point", "")
>>> tablesmplg= arcpy.ListTables("", "")
>>> for table in tablesmplg:
... for fc in fclist2:
... arcpy.JoinField_management(table, "NEAR_FID", fc, "OBJECTID", "")
...
Runtime error Traceback (most recent call last): File "<string>", line 3, in <module> File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 6597, in JoinField raise e ExecuteError: ERROR 000499: table is not editable Failed to execute (JoinField).
Trial 2
>>> in_data= arcpy.ListTables("", "")
>>> in_field= "NEAR_FID"
>>> join_table= arcpy.ListFeatureClasses("D*", "point", "")
>>> join_field="OBJECTID"
>>> for table in in_data:
... for fc in join_table:
... arcpy.JoinField_management(in_data, in_field, join_table, join_field, "")
...
Runtime error
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 6597, in JoinField
raise e
RuntimeError: Object: Error in executing tool
for fc, table in zip(fclist2, tablesmplg):
this will iterate over both lists at the same time