how can i split a string to the first space

2324
9
10-25-2018 12:28 PM
COTA_GISAdmin
New Contributor

I am trying to split an address field in arcmap using the field calculator

for example...

2387 Resource Rd. Apartment 34

and i need to get rid of of the first set of numbers (2387)

Resource Rd. Apartment 34

I try using the split / lsplit / rsplit functions but i am doing something wrong. 

any ideas?

thanks for your help in advance. 

0 Kudos
9 Replies
DanPatterson_Retired
MVP Emeritus
a = "first second third"

a.partition(" ")
Out[2]: ('first', ' ', 'second third')

will get you started

DanPatterson_Retired
MVP Emeritus
"".join(a.partition(" ")[1:]).strip()
'second third'

then use the bits

HugoMorales
New Contributor II

Thanks for your time and help.

0 Kudos
BalajiVeera
Occasional Contributor

Try this python expression

' '.join(!ADDRESS!.split(' ')[1:])

HugoMorales
New Contributor II

Thanks for your help, this works perfectly for what i need

0 Kudos
DanPatterson_Retired
MVP Emeritus

partition will answer more questions that a simple split.  It is often overlooked

a = "123 Main Street South"

# ---- partition, slice, and join

"".join(a.partition(" ")[1:]).strip()

'Main Street South'

# ---- split,slice, and join
"".join(a.split(" ")[1:])
'MainStreetSouth'

a = !Address!   I use 'a' to represent the field

HugoMorales
New Contributor II

thanks a lot ... i really appreciate your time and help... I finally figure out ... using your advice and also using others advice that reply to my question... 

this was my first time submitting a question and i was wondering how it will work... i have to say its awesome. 

thanks again.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Glad it worked out Hugo

0 Kudos
JoeBorgione
MVP Emeritus

A little late in the game but here's a thread I started a couple years back and still refer back to:

https://community.esri.com/thread/163731 

That should just about do it....
0 Kudos