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!
Solved! Go to Solution.
>>> s = "Wind Ruisseau"
>>> " ".join(s.split()[::-1])
'Ruisseau Wind'
>>>
"West Wind"+' ' +"Ruisseau"
I need to do it for thousands of unique names that end with "Ruisseau" and make them start with "Ruisseau"
Are the unique names in a specific field you can call out? In this case, you could use the field calculator to do this:
"Ruisseau"+' ' +[FIELD NAME]
Ah yes, that's a much more simple solution than I was thinking. I think this should work, thank you!
>>> s = "Wind Ruisseau"
>>> " ".join(s.split()[::-1])
'Ruisseau Wind'
>>>
Thanks! I'll give this a try as well.
Can I make my field equal s? like s = !Nom! so it selects my selected rows from this field?
Just tried with field name, which absolutely works! Thanks kindly.
Hi Joshua,
Is there a way to I could keep the order of the middle words when there are three words in the string?
For example, this expression also reverses the names of the other words:
'West Wind Ruisseau' becomes 'Ruisseau Wind West'
and I would like 'Ruisseau West Wind'
Here's another solution to consider.
s = "West Wind Ruisseau"
s = s.rsplit(" ", 1)
last_word = s.pop()
s = " ".join([last_word] + s)