I have a script that joins one table to another, then calculates one column to another. Everything works as it should, but it takes 4 hours to do so if it is scripted while it only takes a few seconds if I do it manually. The script actually does a lot more in that it loops through 4 tables and joins them each to 3 different tables. This is a process that needs to occur fairly regularly, so this is not something I really want to be doing manually every time I need to update these columns.
After my first attempt ran for 4 hours, I thought I might give da.SearchCursor / da.UpdateCursor a go. But after it ran for 6 hours I gave up.
Is there a better way to skin this cat?
Code:
FieldNameList = ["CATTLE", "DAIRY", "POULTRY", "SWINE"]
Iteration = 0
Iteration2 = 0
if TABLETYPE == "Animal Operations":
for JoinFile in UPDATELIST_join:
if Iteration > 2:
Iteration = 0
Iteration2 = Iteration2 + 1
layer = CENSUSLayerLIST[Iteration]
ANOPSFIELD = FieldNameList[Iteration2]
arcpy.AddJoin_management(layer, "GEOID10_1", JoinFile, "GEOID10_1", "KEEP_COMMON")
arcpy.CalculateField_management(layer, ANOPSFIELD, "!NumCount!", "PYTHON_9.3")
arcpy.RemoveJoin_management(layer)
Iteration = Iteration + 1
else:
for layer in CENSUSLayerLIST:
JoinFile = UPDATELIST_join[Iteration]
arcpy.AddJoin_management(layer, "GEOID10_1", JoinFile, "GEOID10_1", "KEEP_COMMON")
arcpy.CalculateField_management(layer, CENSUSFIELDTRANS, "!NumCount!", "PYTHON_9.3")
arcpy.RemoveJoin_management(layer)
Iteration = Iteration + 1
Is there a better way to skin this cat?