I'm trying to calculate a field from another field using arcpy. If the field contains the word Diversion, I want it to calculate the other field with the value 3. If it conctains 'Dam' I want it to calculate 9, otherwise keep it null.
When I try to execute this in the python window, itlooks like it's working, but my field is still null. The new field is a long integer. Please Help!
Category = "StructureCategory"
expression5 = "Reclass(!StructureT!)"
codeblock = """def Reclass (newdams_schema):
if 'Diversion' in newdams_schema:
return 3
elif 'Dam' in newdams_schema:
return 9
else:
return None"""
# Execute CalculateField
arcpy.CalculateField_management(newdams_schema, Category, expression5, "PYTHON_9.3")