Remove text from a string using python or arcade

6145
4
Jump to solution
07-22-2019 06:59 AM
SaloniRajput
New Contributor III

I need some help with a field calculator expression, using python or arcade, in ArcGIS Pro

I have an address field that has full address, with street number and name, I want to remove the number and retain only the street name, since the number of digits in the address could vary so I want to remove everything that comes before the space, so first word or an element. I am trying to do this using field calculator in ArcGIS Pro, so either Python 3 or Arcade.

For example :

3405 S 51st St

would result in

S 51st St

I tried this

!ADDRESS!.split(" ")[1:] , it did not work.

I looked at this https://community.esri.com/thread/233144-remove-text-in-parenthesis-with-arcade

 but couldn't figure out how to do this with arcade.

If I can get some help with correct syntax for python or an arcade expression would be great.

Thanks

0 Kudos
1 Solution

Accepted Solutions
LanceCole
MVP Regular Contributor

Saloni,

Using Python !ADDRESS!.split(" ", 1)[1] should work for you assuming there are no leading spaces before the address number and addresses do not contain any unit numbers such as "123 C Main Street".  You can add a strip() statement to remove leading and trailing spaces such as !ADDRESS!.strip().split(" ", 1)[1].

View solution in original post

4 Replies
LanceCole
MVP Regular Contributor

Saloni,

Using Python !ADDRESS!.split(" ", 1)[1] should work for you assuming there are no leading spaces before the address number and addresses do not contain any unit numbers such as "123 C Main Street".  You can add a strip() statement to remove leading and trailing spaces such as !ADDRESS!.strip().split(" ", 1)[1].

MarkBockenhauer
Esri Regular Contributor

Using Arcade you could so something like this:

var firstSpace = find(' ',$feature.ADDRESS,0)
var strCount = count($feature.ADDRESS)
var strDiff = strCount - firstSpace


return right($feature.ADDRESS, strDiff)

SaloniRajput
New Contributor III

Thanks, Mark. This worked too.

0 Kudos
SaloniRajput
New Contributor III

Wow, both the options worked, perfectly, Thanks

0 Kudos