if not row.CNT_PT_ID : cur.deleteRow(row)
Dear FLBBIt gives me Following ErrorTraceback (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: isNULLFailed to execute (LISTool1.0).Thanks
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 rowyou may also be able to get away with deleting the isdigit() line.
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()
Try changing CNT_PT_ID" = "Null" to be "CNT_PT_ID" IS NULL instead. Does that work?
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.