0

I am trying to change a title based on a feature class named Subject. They are parcel addresses, and the StrUnit field is the unit number. The issue is, not all of the parcels are apartments, so when it displays the title, it will show the address then the word "none". I tried to create a cursor to search the row where the unit number would be, if it's null it would delete the row, if not, keep it. Problem is, I'm not getting any error messages and it's still displaying None. Any ideas?

import arcpy
relateFC = r"Subject"
relateFieldsList = ["StrNum", "Street", "StrSuf", "StrUnit"]

with arcpy.da.UpdateCursor(relateFC, relateFieldsList) as cursor:
    for row in cursor:
        if row[3] == " " :
            cursor.deleteRow()

with arcpy.da.SearchCursor(relateFC, relateFieldsList) as cursor:
    for row in cursor:
        print("COMPARABLE SALES FOR ID # " + \
                        "Subject" + '\n' + '{} {} {} {}'.format(row[0], row[1], row[2], row[3]))
2

" " is a string with a single space. None indicates a null value. You have a couple options:

if not row[3]: ##returns true if row[3] is "", None, 0, []...
         cursor.deleteRow()

or:

if row[3] == None:
         cursor.deleteRow()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.