Hello,
I am writing a for loop to iterate through the join field tool on a geodatabase of tables. My final goal is to have one table containing the fields of all other tables in the GDB. Here is the relevant code:
arcpy.env.workspace = r"C:\My_GDB.gdb"
join_field = "CommuneCode"
join_table = r"C:\My_GDB.gdb\chirps_2020_04_tbl"
tables = arcpy.ListTables()
counter = 1
for table in tables:
print ("processing: " + table)
arcpy.JoinField_management(table, join_field, join_table, join_field)
print("%s of %s tables processed" % (counter, len(tables)))
counter += 1
print("Processing complete.")
The actual results of this loop appends the fields from the join_table object onto each of the tables in the GDB. What I would actually like is the opposite, joining all tables in the GDB to the join_table.
I would greatly appreciate any tips here. Thanks in advance!
Solved! Go to Solution.
Join Field (Data Management)—ArcGIS Pro | Documentation
did you try switch their order around?
Hi @DanPatterson thank you! I had also tried reversing the order but was still getting the same result. The suggestion from Joe Borgione to run Add Join worked for my use case.
Don't you want to add a join?
Hi @JoeBorgione , thanks for the suggestion - this is what I needed. Sometimes the simpler option is the best one!