I have a script I want to use to update a value for a group of selected features in ArcMap in a string field. I am using the UpdateCursor method but I cannot get the output generated that I want. I know my code is close but something is off. Here is my code:
import arcpy
fc = r'D:\_data\sidewalk.gdb\repairs'
cursor = arcpy.UpdateCursor(fc)
for row in cursor:
if row.FixedBy == '':
row.FixedBy = 'Contractor'
cursor.updateRow(row)
print "Processing complete"
del row
I am trying to update the string "FixedBy" field where values are blank, not 'Null', with the value 'Contractor'. What is my code missing?
cursor.updateRow(row)should be unindented. Try replacingrow.FixedBy == ''withrow.FixedBy == None. Also, I would recommend using the new data accessdacursors. – Aaron Jun 08 '17 at 13:41printstatement within your cursor to see what the true value is of yourrow. – Aaron Jun 08 '17 at 13:52row.YourFieldName = 'Contractor'berow.FixedBy = 'Contractor'if you are trying to update this field? – Emil Brundage Jun 08 '17 at 16:24