4

I want to split a string field after the first word using the space as a delimiter so that:

"WA ROSSOUW ORANJE BELEGGINGS" becomes "ROSSOUW ORANJE BELEGGINGS".

I am using ArcMap 10.

nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Mar 30, 2012 at 11:04
1
  • This worked for me. THANKS! Incidentally, if I just wanted to extract ONLY the first word, how would you suggest I modify the VBA code? Commented Apr 29, 2014 at 17:25

3 Answers 3

7

Or the two-liner using Python:

(in Show Codeblock)

 import string

in Class = :

string.join(!YourFieldName!.lstrip().split(' ')[1:],' ')

The lstrip() makes sure there are no leading spaces which will cause problems

answered Mar 30, 2012 at 12:00
2
  • 2
    Python string module functions are deprecated (docs.python.org/library/string.html). String object methods are preferred, e.g. ' '.join(!YourFieldName!.lstrip().split(' ')[1:]) Commented Apr 3, 2012 at 3:28
  • shorter too, so can't argue with that. Commented Apr 3, 2012 at 8:32
1

You can simply use the following VBA code in field calculator :

Split( [Your_Field_Name] , " ", 2)(1)
answered Mar 30, 2012 at 11:27
1
  • Thanks, but I am getting a "failure during processing" message when I use it. Commented Mar 30, 2012 at 11:50
0

you can use python if you want.

text = "WA ROSSOUW ORANJE BELEGGINGS"
sptext = text.split(" ") 
result = ' '.join(sptext[1:len(sptext)])
print result
>>>"ROSSOUW ORANJE BELEGGINGS"
answered Mar 30, 2012 at 12:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.