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.


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 =

| improve this answer | |

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.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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