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]))
Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Sep 23, 2019 at 18:30

1 Answer 1

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()
answered Sep 23, 2019 at 18:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.