Fixing attributes...from St to Street

1728
7
Jump to solution
01-04-2016 01:10 PM
VaneiriKeme
New Contributor III

Hi,

I am trying to fix my attribute records in Arcmap.

Is there a way to do a bulk fixing, to find all my St and change it to Street?

St vs Street.png

0 Kudos
1 Solution

Accepted Solutions
ChrisDonohue__GISP
MVP Frequent Contributor

Here's a simple Python field calculator example:

!fieldnamehere!.replace(' ST', ' STREET')

Longer example for addressing multiple changes.  Use your fieldname instead of FacilityAddress.

def StreetSuffix(FacilityAddress):
  list = FacilityAddress.split()
  for item in range(len(list)):
    if list[item] == 'STREET':
      list[item] = list[item].replace("STREET", "ST")
    if list[item] == 'STREET,':
      list[item] = list[item].replace("STREET,", "ST")
    if list[item] == 'STR.':
      list[item] = list[item].replace("STR.", "ST")
    if list[item] == 'STR,':
      list[item] = list[item].replace("STR,", "ST")
    if list[item] == 'ST.':
      list[item] = list[item].replace("ST.", "ST") 
    if list[item] == 'ST,':
      list[item] = list[item].replace("ST,", "ST")
    if list[item] == 'WAY':
      list[item] = list[item].replace("WAY", "WY") 
    if list[item] == 'WAY,':
      list[item] = list[item].replace("WAY,", "WY") 
    if list[item] == 'WY.':
      list[item] = list[item].replace("WY.", "WY")
    if list[item] == 'WY,':
      list[item] = list[item].replace("WY,", "WY")
  return " ".join(list) 

Credit to Darren Wiens and several others knowledgeable in Python for coming up with this, which I gratefully stole borrowed. 

Chris Donohue, GISP

View solution in original post

7 Replies
DarrenWiens2
MVP Honored Contributor

There is Find and Replace in Table options.

VaneiriKeme
New Contributor III

Thanks Darren!

0 Kudos
ChrisDonohue__GISP
MVP Frequent Contributor

Yes, this can be done in Python.  The Python code can be placed in the field calculator, or a pure Python run can be done.

Chris Donohue, GISP

JoeBorgione
MVP Esteemed Contributor

Or select thuroghfare trailingtype = 'ST' and then calc thuroghfare trainingtype = "STREET"

That should just about do it....
ChrisDonohue__GISP
MVP Frequent Contributor

Here's a simple Python field calculator example:

!fieldnamehere!.replace(' ST', ' STREET')

Longer example for addressing multiple changes.  Use your fieldname instead of FacilityAddress.

def StreetSuffix(FacilityAddress):
  list = FacilityAddress.split()
  for item in range(len(list)):
    if list[item] == 'STREET':
      list[item] = list[item].replace("STREET", "ST")
    if list[item] == 'STREET,':
      list[item] = list[item].replace("STREET,", "ST")
    if list[item] == 'STR.':
      list[item] = list[item].replace("STR.", "ST")
    if list[item] == 'STR,':
      list[item] = list[item].replace("STR,", "ST")
    if list[item] == 'ST.':
      list[item] = list[item].replace("ST.", "ST") 
    if list[item] == 'ST,':
      list[item] = list[item].replace("ST,", "ST")
    if list[item] == 'WAY':
      list[item] = list[item].replace("WAY", "WY") 
    if list[item] == 'WAY,':
      list[item] = list[item].replace("WAY,", "WY") 
    if list[item] == 'WY.':
      list[item] = list[item].replace("WY.", "WY")
    if list[item] == 'WY,':
      list[item] = list[item].replace("WY,", "WY")
  return " ".join(list) 

Credit to Darren Wiens and several others knowledgeable in Python for coming up with this, which I gratefully stole borrowed. 

Chris Donohue, GISP

VaneiriKeme
New Contributor III

Got it fixed. Saved me tons of hours.

0 Kudos
DarrenWiens2
MVP Honored Contributor

Now that I see this again, a more compact alternative may be (only lightly tested):


def StreetSuffix(FacilityAddress):  
  replace_dict = {
    'ST':['STREET','STREET,','STR.','STR,','ST.','ST,'],
    'WY':['WAY','WAY,','WY.','WY,']
  }

  list = FacilityAddress.split()  
  for item in range(len(list)):
    for key, value in replace_dict.iteritems():
      if list[item] in value:
        list[item] = key
  return " ".join(list)