2

I am hoping that someone may be able to help me. I am new to ArcGIS, and even newer to Python.

Working in ArcGIS 10.1, I have done is created a new text field in an attribute table, which I have called "Ag". I want to populate this field with the text from another field (called Address) which is in the same attribute table BUT only if that text starts with the word "Field".

I have written the following function but it is not working, and I am not sure where I have gone wrong, or if I am on the wrong path completely.

def Reclass(agri):
    if (!Address!.startswith("Field")):
      return !Address!
    else:
      return "NA"

I have searched the forums and the ESRI documentation for a solution, but cannot seem to find what I am looking for. I hope that I have given all the relevant information for someone to be able to help me with my conundrum, but please let me know if there is more (or better) information I should supply.

Many thanks in advance!

3

Replace !Address! field with your input parameter agri.

  • Thanks for your reply. I wasn't sure if you meant to change the !Address! in the "if" line or the "return" line. I tried both & in both cases I was thrown the error "Parsing error: unindent does not match any outer indentation level". I understand this is an issue with whitespace, but I have double-checked my indentation & cannot see the problem (2 spaces on the "if"/"else" line and 4 on the "return" line). – tea4two Nov 25 '13 at 14:10

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.