Fixing attributes...from St to Street

1545
7
Jump to solution
01-04-2016 01:10 PM
Highlighted
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

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
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
Highlighted
MVP Honored Contributor

There is Find and Replace in Table options.

Highlighted
New Contributor III

Thanks Darren!

Reply
0 Kudos
Highlighted
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

Highlighted
MVP Esteemed Contributor

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

Highlighted
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

Highlighted
New Contributor III

Got it fixed. Saved me tons of hours.

Reply
0 Kudos
Highlighted
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)