AnsweredAssumed Answered

Join tables to feature classes in batch

Question asked by Padmini_Ottawa on Jun 13, 2017
Latest reply on Jun 14, 2017 by blake.terhune



I need some help with batch processing using python. I am trying to join fields to multiple point features classes from multiple dbf tables (650 feature classes and tables). Names of the dbf tables match names from each feature class. I have got the script so far; I am not sure where I went wrong as the script runs but feature classes are not updated with the join. I am using instead of Add Join because I want to update the feature classes directly without having to create feature layer and save. If this where I am wrong, please let me know.

Any help is highly appreciated. My script so far is below:



import arcpy, os 
from arcpy import env 
 # Add variables 
GDB1 = r"C:\test\GDB1.gdb" 
GDB2 = r"C:\test\GDB2.gdb" 
joinField = "Work_ID" 
env.workspace = GDB1  
 #Join tables 
for fc in arcpy.ListFeatureClasses():         
    env.workspace = GDB2 
    for table in arcpy.ListTables(): 
                if table() == fc(): 
                            arcpy.JoinField_management(GDB1 + os.sep + fc, joinField, GDB2 + os.sep + table, joinField, "")

                           arcpy.AddMessage("Could not join ") 
env.workspace = GDB1