Select to view content in your preferred language

Fixing attributes...from St to Street

2601
8
Jump to solution
01-04-2016 01:10 PM
VaneiriKeme
Deactivated User

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 Alum

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

8 Replies
DarrenWiens2
MVP Honored Contributor

There is Find and Replace in Table options.

VaneiriKeme
Deactivated User

Thanks Darren!

0 Kudos
ChrisDonohue__GISP
MVP Alum

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 Emeritus

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

That should just about do it....
ChrisDonohue__GISP
MVP Alum

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
Deactivated User

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)

   

JM32
by
Regular Contributor

@ChrisDonohue__GISP 

I just wanted to thank you for posting this field calculator expression. I needed to update addresses in a single field to change all abbreviations to fully spelled out words. I used this expression in ArcGIS Pro, created a list of changes I needed, and updated over 16000 records with little issues. It worked great!! A huge time saver, and I learned some good skills from it. 

Thank you!

Jon

0 Kudos