arcpy.MakeFeatureLayer_management(FC, "FC_lyr") FC_lyr = "FC_lyr" arcpy.AddJoin_management(FC_lyr, "joinField", joinedFCTable, "joinField") fields =("{}.DataField".format(FC_lyr), "{}.OtherDataFiedl".format(joinedFCTable)) where = '"{}.OBJECTID" IS NOT NULL'.format(joinedFCTable) with arcpy.da.UpdateCursor(FC_lyr, fields, where) as rows: for row in rows: row[0] = row[0] + row[1]
Solved! Go to Solution.
arcpy.AddMessage(str(joinDict[joinFieldValue][13]))
strJoinFieldValue = str(joinFieldValue) arcpy.AddMessage((joinDict[strJoinFieldValue][13]))
where it is working there are the same number of records in the update and join tables (one record in each table). Where it isn't working, the join table only has a few matches in the update table
lutDict = dict([(r[0], (r[1], r[2])) for r in arcpy.da.SearchCursor(lutTbl, ["SOURCEJOINFIELD","SOURCEFIELD1","SOURCEFIELD2"])]) updateRows = arcpy.da.UpdateCursor(targetTbl, ["TARGETJOINFIELD","TARGETFIELD1","TARGFETFIELD2"]) for updateRow in updateRows: joinFieldValue = updateRow[0] if joinFieldValue in lutDict and joinFieldValue != None: updateRow[1] = updateRow[1] + lutDict[joinFieldValue][0] updateRow[2] = updateRow[2] * lutDict[joinFieldValue][1] else: updateRow[1] = -9999 updateRow[2] = -9999 updateRows.updateRow(updateRow) del updateRow, updateRows