7

I'm trying to find part of a text string in the CLASS_NAME field and return a text string to the Abrv_Name field using the Field Calculator in ArcGIS 10 via a Python parser.

Here is what I have tried among other things with no success.

field calculator image


This worked within the field calculator.field calculator

2 Answers 2

12

You want the in method detailed here: http://docs.python.org/reference/expressions.html#in

Swap

if Name=="*Emergent*":

with

if "Emergent" in Name:
4

If you are specifically looking for wildcard behavior (probably not in this case) you can try the fnmatch module. Example:

from fnmatch import fnmatch

if fnmatch(Name, "*Emergent*"):
    return 'EM'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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