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[0] is 'NULL' or row[0] == '':
pidgis = row[1]
upCursor.updateRow([pidgis[:2]+'-'+pidgis[4:6]+'-'+pidgis[6:7]+'-'+pidgis[7:10]+'-'+pidgis[10:13]+'.'+pidgis[13:]],[pidgis])
elif row[1] is 'NULL' or row[1] == '':
pid = row[0]
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.