import arcpy from arcpy import env env.workspace = r"C:\Users\cc1\Desktop\NEW.gdb\WAYNE" table = "WAYNE" list = [] with arcpy.da.SearchCursor(table, ["FULL_ADDRESS_NAME"]) as cursor: for row in cursor: list.append(row[0]) del row, cursor with arcpy.da.UpdateCursor(table, ["FULL_ADDRESS_NAME","FEAT_SEQ"]) as updateRows: for updateRow in updateRows: nameValue = updateRow[0] if nameValue in list: updateRow[1] = lutDict[nameValue] updateRows.updateRow(updateRow) del updateRow, updateRows
This is a good start. A few things though. For one, I would avoid naming any variables you define things like list, dict etc that might get confused with list(), dict() etc. Also, you will probably throw errors because you are calling the row variable updateRow but also calling the method updateRow. This is generally a bad idea, you should keep names unique so the code is clear.But your general idea is almost right on. My thought would be that you only need the update cursor, you can do without the first cursor if you use a dictionary instead of a list to store the values. Try this (granted that I can't test it for myself):import arcpy from arcpy import env env.workspace = r"C:\Users\cc1\Desktop\NEW.gdb\WAYNE" table = "WAYNE" uniqueValues = {} newID = 1 with arcpy.da.UpdateCursor(table, ["FULL_ADDRESS_NAME","FEAT_SEQ"]) as updateRows: for row in updateRows: nameValue = row[0] if nameValue in uniqueVals: row[1] = uniqueValues[nameValue] else: newID += 1 uniqueValues[nameValue] = newID row[1] = newID updateRows.updateRow(row) del row, updateRows
And you are right about the cursors - in general they tend to be much faster.