I have a function I'm trying to incorporate in a model. It's supposed to check to see if one of two fields have a value and depending on the field with value calculate the other.
The issue I'm having is writing the result back into my feature using the UpdateCursor. I don't have any experience using it, and not sure if it's the right tool for the job. Here's my function:
import arcpy upCursor = arcpy.da.UpdateCursor("SepticTankPermit layer", ['pid','pidgis']) def autoCheck(): with arcpy.da.SearchCursor("SepticTankPermit layer",['pid','pidgis']) as cursor: for row in cursor: if row is 'NULL' or row == '': pidgis = row upCursor.updateRow([pidgis[:2]+'-'+pidgis[4:6]+'-'+pidgis[6:7]+'-'+pidgis[7:10]+'-'+pidgis[10:13]+'.'+pidgis[13:]],[pidgis]) elif row is 'NULL' or row == '': pid = row upCursor.updateRow([pid],[pid[:2]+'00'+pid[3:5]+ pid[6:7]+ pid[8:11]+ pid[12:15]+ pid[16:]]) else: print "PID or PIDGIS must have a value in order to execute properly!"
I'm not sure if I'm using it correctly.