When working with search and update cursors, how do I call upon a specific row?
In this example:
import arcpy, os
# I want to find a row where the FID is 10
# print value field in the row where FID is 10
fc = 'c:\example.shp'
fields = ['Value']
with arcpy.da.SearchCursor(fc, fields) as cursor:
for row in cursor:
print(u'Row with FID = 10 has value {0}'.format(row[0]))
However when using the code above, of course it prints out all the values, but I'm not quite sure what the easiest way to set the cursor to only print out the FID= 10 row would be.
In this example, I am trying to replace the value in the row where FID is 10 from where Value is 5 to Value is 10
fc = 'example.shp'
fields = ['Value']
cursor= arcpy.da.UpdateCursor(fc,fields)
try:
for fid120 in cursor:
row[0] = '10'
row[1] = row[1].title()
cursor.updateRow(row)
print 'Row with FID = {0} has been updated to 25: {1}'.format(row[0], row[1])
del cursor
except:
print 'help'
del cursor
However again, I keep getting stuck with how to begin on calling the specific row to update it. One thing I tried to no avail is setting a variable equal to the FID I want to call, and creating an if statement akin to x = 10 'if row[0] = x' but that doesn't seem to work as well.