I am trying to remove prefixes from a table. I have the following code but it removes more than just street prefix. I my code I have E "space", "E ". I need to be able to strip the prefixes so I can sort, then delete duplicates. How can I remove just the prefixes?
with arcpy.da.UpdateCursor(table1,'STREET') as cursor:
for row in cursor:
#print row[0]
if row[0].startswith("S "):
#print "Deleting S"
row [0] = row[0].lstrip('S ')
elif row[0].startswith("E "):
#print "Deleting E"
row [0] = row[0].lstrip('E ')
elif row[0].startswith("W "):
#print "Deleting W"
row [0] = row[0].lstrip('W ')
elif row[0].startswith("N "):
#print "Deleting N"
row [0] = row[0].lstrip('N ')
cursor.updateRow(row)
del cursor After code runs i get.
| Before Code | After code |
| E Explorer | xplorer |
| E Expedition | xpedtion |
| E Exective | xecutive |
| E Exchange | xchange |