Is there a Python expression for Does Not Contain that I can use in a Update Cursor? I am looking for the '@' symbol in a column within a table (not a FC) and want to delete all entries without one, is there a way accomplish this?
1 Answer
For the WHERE clause in your Update Cursor use
myField NOT LIKE '%@%'
The '%' sign is a wildcard character representing any number of characters, including 0 characters.
The call would look something like this.
cursor = arcpy.da.UpdateCursor(contacts, #your table
['*'], #your fields
"Contact_Email NOT LIKE '%@%'") #your where clause
for row in cursor:
cursor.deleteRow()
del cursor
-
-
with arcpy.da.UpdateCursor(contacts, "Contact_Email") as cursor: for row in cursor: if row NOT LIKE '%@%': cursor.deleteRow() Mar 15, 2017 at 19:35
-
1
-
-
2@winscott68 The cursor itself is already limiting what is returned based on the where clause. There is no need to compare the specific row to the pattern string again.– danielmMar 16, 2017 at 14:36