AnsweredAssumed Answered

Remove predirectional from attribute table

Question asked by CCweedcontrol on Apr 12, 2018
Latest reply on Apr 24, 2018 by CCweedcontrol

I have a table that i am trying to remove just the street predirectional's of the table. I have the following code but it removes more than just the predirectional's from the street name. For example N St Alphonusu Way to turn into T Alphonsus Way. I just want to remove the "N", "E", "W" & "S" from the street name. How can do this correctly?

 

lyr = "C:\Temp\Default.gdb\CurrntRoadNamesTableTest_1"


for field in arcpy.ListFields(lyr, "*", "String"): 
    with arcpy.da.UpdateCursor(lyr, ['STREET']) as cursor: 
        for row in cursor: 
          s = row[0]
          row[0] = s.lstrip('W ')
          a = row[0]    
          row[0] = a.lstrip('E ')
          b = row[0]
          row[0] = b.lstrip('N ')
          X = row[0]
          row[0] = X.lstrip('S ')

          cursor.updateRow(row)
del cursor

Outcomes