I am trying to automate the creation of many different feature layers were their content is created by a cursor. Sometimes during the automation, a feature layer may be empty, this is okay, but as the cursor runs through the layer adding in the data, the
del row line returns the error:
"NameError: name 'row' is not defined" and stops the script.
Question: If a layer I am creating happens to be empty, how can I skip over any errors that might pop up due to the cursor not being able to define itself in an empty table?
Already Tried: I tried setting a 'count' variable to how many rows are in each table, and telling python to skip over the table if it has less than 1 row, but the "del row" line still caused a fuss, and I had trouble setting up the try statement.
The code below is still returning the error. It is not printing empty cursor yet the
ACount is indeed 0.
cursor = arcpy.da.UpdateCursor("A_Squares", ["LEGEND"]) ACount = arcpy.GetCount_management("A_Squares") print ACount if ACount == 0: print "empty cursor" else: for row in cursor: row = TableA cursor.updateRow(row) del row del cursor