I am writing my very first script in Python 2.7. (And this is my very first question/post here and about Python scripting at all)
Solved/found out almost all problems except one.
I can not figure out how to write the following for arcpy.da.UpdateCursor:
if row[0] is equal row[1] then row[2] is None
Any suggestion is appreciated.
I am expecting a relevant answer to my question.
EDIT: Here is the working code and a solution to my question.
import arcpy
fc = 'C:/DB/yourDB.gdb/yourFeatureClass.shp'
fields = ['field0', 'field1', 'field2']
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
if (row[0] == row[1]):
row[2] = None
cursor.updateRow(row)
del cursor
Here is the correct code and a solution for my question.
import arcpy
fc = 'C:/DB/PGDB.gdb/Parcel_point.shp'
fields = ['NEWNUMBER', 'NEWNUMBER1', 'NEWNUMBER2']
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
if (row[0] == row[1]):
row[2] = None
cursor.updateRow(row)
del cursor