Try changing CNT_PT_ID" = "Null" to be "CNT_PT_ID" IS NULL instead. Does that work?
cur = arcpy.UpdateCursor("CNT_Anno") for row in cur: val1 = row.getValue("Some attribute field") if val1.isdigit(): if int(val1) >= 9000: row.setValue("CNT_PT_ID", int(val1)) cur.updateRow(row) if row.isNull("CNT_PT_ID")==True: cur.deleteRow(row) del cur del row
layer = r'CNT_Anno' cur = arcpy.da.UpdateCursor(layer, ['TextString', 'CNT_PT_ID']) for row in cur: if row[0]: try: if int(row[0]) >= 9000: row[1] = int(row[0]) cur.updateRow(row) except: pass if row[1] is None: cur.deleteRow()
It should look something like this:cur = arcpy.UpdateCursor("CNT_Anno") for row in cur: val1 = row.getValue("Some attribute field") if val1.isdigit(): if int(val1) >= 9000: row.setValue("CNT_PT_ID", int(val1)) cur.updateRow(row) if row.isNull("CNT_PT_ID")==True: cur.deleteRow(row) del cur del row
you may also be able to get away with deleting the isdigit() line.
Dear FLBB
It gives me Following Error
Traceback (most recent call last):
File "J:\Gampaha\Scripts\Script1.py", line 109, in <module>
if row.isNULL("CNT_PT_ID")==True:
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 28, in __getattr__
raise AttributeError("%s" % attr)
AttributeError: isNULL
Failed to execute (LISTool1.0).
Thanks
if not row.CNT_PT_ID : cur.deleteRow(row)