Hi - I'm trying to write a little bit of code to assign a random value to my ORIENT field where ORIENT = 0.
My problem is that it chages the ORIENT for the whole table not just where the value is zero.
I guess that this is because line 14 does not refer to row but I don't know how to charge it so it does refer to row - can anyone advise??
import arcpy fc = r"c:\Test_Orient.shp" feildName = "ORIENT" expression = "rand_num()*360" codeblock = """def rand_num(): import random return random.random()""" #search for rows to be altered rows = arcpy.SearchCursor(fc, fieldName + " = 0") for row in rows: arcpy.CalculateField_management(fc, fieldName, expression, "PYTHON_9.3", codeblock)