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?


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:
del cursor
|improve this answer|||||
  • Would it look like the following? – Purplepeopleeater Mar 15 '17 at 19:34
  • with arcpy.da.UpdateCursor(contacts, "Contact_Email") as cursor: for row in cursor: if row NOT LIKE '%@%': cursor.deleteRow() – Purplepeopleeater Mar 15 '17 at 19:35
  • 1
    @winscott68 what happened when you tested that? – PolyGeo Mar 15 '17 at 20:09
  • @winscott68 I added the call to UpdateCursor to my answer. – danielm Mar 15 '17 at 20:39
  • 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. – danielm Mar 16 '17 at 14:36

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.