I am trying to use dictionary to help update a field. I have the following but I am getting an error.
Basically, if field "Type" has PVT, I want it to update with "Private" and if Pub, I want it to update with "Public".
the filed doesn't get updated. I am assuming that dict is wrong?
import arcpy
fc = r"C:\Temp\test.gdb\Testb"
search_feats ={f[0]:(f[:1] for f in arcpy.da.SearchCursor(fc,"Type")}
print(search_feats) #'OID@', 'Type'
place_dict = {"PVT": "Private",
"Pub": "Public"
}
with arcpy.da.UpdateCursor(fc,"Type") as upd_cur:
for upd_row in upd_cur:
if upd_row[0] in place_dict:
upd_row[0] = place_dict.get(search_feats[upd_row[0]], upd_row[0])
upd_cur.updateRow(upd_row)