Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write a script (Python or VB) in Field Calculator which can pick up or choose the fist letters of words and put them in a new field.

For example:

Lepidium catapycnon..........> Lc
Gold blossom tree............> Gbt

I'm thankful if someone can help me with it.

share|improve this question
up vote 7 down vote accepted

Expanding on the answer from cag I just tested the code below which should do what you want. You just need to have your original and new field (called OrigField and NewField in my test) already in the attribute table.



Pre-Logic Script Code

def Abbreviate(origFieldValue):
  newFieldValue = "".join(item[0] for item in origFieldValue.split())
  return newFieldValue

NewField =

share|improve this answer
Worked pretty well. Thanks heaps. – Matt May 14 '12 at 14:50

You can do it by splitting the words by groups of consecutive whitespaces and taking the first letter of each word. You've got a python example here.

share|improve this answer
Thanks.............................. – Matt May 14 '12 at 14:57

Does it have to be in python or vbscript? If you can write in sql it would be something like SELECT SUBSTR(Column, 1, 2) where Column would be the name of the corresponding attribute column.

share|improve this answer
Thanks...................................... – Matt May 14 '12 at 14:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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