In my attribute i have 2 columns i need to address. the layer is water valves and the 2 columns are valve size and exercised picture is attached. i need to reset my exercised column from yes back to null annually which i have the script for but i need to address the valve size 6",8",10",12" etc. individually so i can reset just that valve size. any ideas are appreciated.
thanks in advance
I would just use a simple field calculation with python. either GP tool or right-click on the field in the attribute table and select calculate field. I would also make a copy/backup of your data before doing anything.
Calculate Field (Data Management)—ArcGIS Pro | Documentation
select Python as the language and then something like (NB you have aliases for your fields so use their real names in the below code):
if !valve_size! == '12"':
return None
Can you perhaps check what the real field name is?
No that's a picture of the attribute table with the field aliases.
Just find the fieldname in the expression window, then:
#enter this in the box below the '='
myFunction(!The name of your field as it appears in the fields window above!)
#enter this in the 'code block' window
def myFunction(size)
if size == '12"':
return None
So it sounds like you'd like to modify your python script to not only set the "Exercised" column back to NULL but also to do something with valve size. I can't exactly tell from your question what you need to do with the "Valve Size" column. Perhaps, you are wanting to just reset the "Exercised" column to NULL for valves of a certain size? If that is the case, I would use an update cursor with a where clause.
# set up an update cursor including any fields that you'll need updated or to determine what to update
with arcpy.da.UpdateCursor(fcPath, field_names=['UNITID', 'VALVESZ', 'Exercised'], where_clause='VALVESZ IN (6, 8, 10)') as cursor:
for valve in cursor:
if (valve[2] != None): # None is python's equivalent of NULL
valve[2] = None
cursor.updateRow(valve)