Removing text after comma

1030
4
Jump to solution
09-18-2018 01:27 PM
MelissaDrake
New Contributor II

I have a field contains owners name

Doe, John and Jane

I am trying to remove everything so just the last name shows
Doe

I have tried several codes but nothing is working so far. I have Desktop 10.4

Could anyone give me some help please?

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor

python parser in the field calculator, no need for a codeblock if it is a text field

!YourFieldName!.split(",")[0] 

View solution in original post

4 Replies
HåkonDreyer
Esri Contributor

Guessing you are using the field calculator, add a little Pre-Logic code:

def justname(txt):
   return txt[0: txt.find(',')]

Field calculator

MelissaDrake
New Contributor II

Thank you! It worked

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

python parser in the field calculator, no need for a codeblock if it is a text field

!YourFieldName!.split(",")[0] 
MelissaDrake
New Contributor II

Thank you! I really appreciated the help.

0 Kudos