2

I'm trying to use the field calculator to poplulate a string field in a table based on info in another string field. This is what I have:

def Reclass(Correction_Comments):
     if (MSAGSTREETNAME) = 'HEMLOCK':
         return 'IN PARCEL 103'

In the call box:

Reclass( !Correction_Comments!)

I keep getting a parsing error. What's wrong?

5

The parameter "Correction_Comments" from your function is not used at all within the function. Instead, there is a variable "MSAGSTREETNAME", a local variable that is not referenced elsewhere. In addition, the if statement is using an assignment (=) rather than a test (==).

Modifications:

def Reclass(streetnamefield):
     if streetnamefield == 'HEMLOCK':
         return 'IN PARCEL 103'


Reclass( !Correction_Comments!)

This will pass the field Correction_Comments into your Reclass function. You may instead want to run this in the Field Calculator for the Correction_Comments field, against the MGAGSTREETNAME field e.g. right click Correction_Comments, Field Calculator, and run with Reclass(!MGAGSTREETNAME!).

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.