I'm joining a table to a layer file, calculating a field in the layer and then removing the join. The code below runs with no errors, but when I check the field in the attribute table, nothing has been updated. If I do this manually in ArcMap with Field Calculator, all is good. What am I missing?
checkds = 'AllCounties' # don't want to calculate values for this feature class
fields = {'FMCDL' : 'CityLeft', 'FMCDR' : 'CityRight'}
lyr = 'Working'
join_table = os.path.join(targetGDB, 'MunicipalCodes')
arcpy.MakeTableView_management(join_table, 'tblvw')
join_field = 'Code'
calcFrom = '!MunicipalCodes.Description!'
fds = 'Framework'
fclasses = getFeatureClasses(fds)
if fclasses: # make sure feature classes were returned
if checkds in fclasses:
fclasses.remove(checkds) # remove unwanted feature class
for ds in fclasses: # each feature class
working_lyr = ds #+ '_' + lyr # layer name must be unique for each feature class
arcpy.MakeFeatureLayer_management(ds, working_lyr)
for k, v in fields.iteritems(): # each city left and right field
try:
print('\tAdding join...')
arcpy.AddJoin_management(working_lyr, k, 'tblvw', join_field)
arcpy.CalculateField_management(working_lyr, v, calcFrom, 'PYTHON_9.3')
arcpy.RemoveJoin_management(working_lyr)
join_table
a Table View or just a path to a table?