AnsweredAssumed Answered

Arcpy - delete attribute data if string starts with..

Question asked by Michipoo on Aug 18, 2014
Latest reply on Aug 19, 2014 by bixb0012

Here's what I'm trying to do.

 

I have a shapefile called 'Roster' with an attribute table like the one below.

 

NAMEAgeRoom
***John23B
***Alice56C
Tina34A

 

I would like to search the shapefile and delete any data under the field 'NAME' where the string starts with '***'

 

The resulting table would look like this

 

NAMEAgeRoom
23B
56C
Tina34A

 

I figured out how to replace the '***' string with another string, but I can't figure out how to delete the entire cell....

 

def removeName(shapefilePath):
  cursor = arcpy.da.UpdateCursor(shapefilePath, ["NAME"]) 
  for row in cursor: 
       row[0] = row[0].replace("***", None)
       cursor.updateRow(row)
  del row
  del cursor

Outcomes