I am writing a python script that reads a csv file that contain the OBJECTID and a CompKey. I am using a csv dictionary to store the values in. Once they are read in, I want to use an updatecursor to update the compkey based on a matching OBJECTID, but I can't get the update cursor to find any matching values. My update cursor looks like this:
with arcpy.da.UpdateCursor(fc, fc_fields) as cursor:
for row in cursor:
OBJECTID = (row[0])
print OBJECTID
# this loop is to assign each field in the dictionary to the cooresponding field in the fc_fields list
if csvdict.has_key(OBJECTID):
print('found OBJECTID for {}'.format(OBJECTID))
row[1] = csvdict[OBJECTID][0]
cursor.updateRow(row)
print cursor
else:
print ('no matching OBJECTID')
When I run the entire script all I get is the no matching objectid. The above script worked when comparing
to a field other than OBJECTID. When I change OBJECTID to UNITID, it works, the problem is UNITID is not a
unique value, so I am getting duplicates. Any help would be greatly appreciated.