0

I have a column in an attribute table and I want to split it with the field-calculator in arcis in a way that I get everything after the 4th blank (space) in a new column:

I tried it by using !Kreuzungsname!.split(" ")[4]+!Kreuzungsname!.split(" ")[5] in the field calculator, but the problem is that some of the entries only contain 4 and not 5 blanks.

Is there a way to get everything after the 4th blank?

1 Answer 1

4

with python, you can do this:

" ".join(!kreusungname!.split(" ")[4:])

split to create a list, take elements from 5 to the end, and join back with a space between.

1
  • More generally you might want to take a look at list slicing notation in python. That's how you you say "items M through N" rather than accessing individual items one at a time. The accepted answer by Greg Hewgill in this StackExchange post gives a pretty good overview. stackoverflow.com/questions/509211/understanding-slice-notation Commented Mar 19, 2021 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.