I need scripts for the field calculator that:
- extracts the first word from a column, i.e. "Jones School" - "Jones", and
- A script that will capitalize this new field, "Jones" - "JONES".
This is Arc 10.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Assuming you consider a space as a separator:
!myField!.split(" ").title() # Proper Case !myField!.split(" ").upper() # Upper Case
UCase(Left([myField],1)) & LCase(Mid([myField],2,InStr([myField]," ")-1)) ' Proper Case UCase(Mid([myField],1,InStr([myField]," ")-1)) ' Upper Case
The Python string manipulation methods should give you access to all of the features you are looking for: http://docs.python.org/library/stdtypes.html#string-methods
To extract words from a string, take a look at the usage of:
For capitalizing your word(s), take a look at the usage of: