Move last word to first word in field calculator

1025
12
Jump to solution
10-21-2021 08:50 AM
kat_h
by
New Contributor II

Hi!

I'm trying to give watercourse names their French name from their English name, so I need to change the order of words a bit such as:

Wind Ruisseau -> Ruisseau Wind

I can remove Ruisseau with !Nom![:-9], but I can't figure out how to place it in the front with a space.

Some watercourse names hare three words like

West Wind Ruisseau 

Would using an UpdateCursor be more simple than trying to figure out an expression in the Field Calculator?

 

Thanks!

0 Kudos
12 Replies
kat_h
by
New Contributor II

Thanks Blake! I was wondering to workaround it with pop() as well. 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If you just want to make the last word the first word:

>>> s = "West Wind Ruisseau"
>>> " ".join(s.split()[-1:]+s.split()[:-1])
'Ruisseau West Wind'
>>> 
kat_h
by
New Contributor II

That makes sense! Thanks so much!

0 Kudos