calculate field in ARCGIS
Lydia
cssaua at hotmail.com
Thu Apr 9 15:42:39 EDT 2009
Hi Python users,
I ran into a problem with python coding in ARCGIS. Does anybody have the experience in dealing with this?
I need to calculate NEWFIELD based on OLDFIELD under condition: if OLDFIELD == 0 then return string "B" otherwise return "".
codeblock = "def codefun(code): if code == 0: return \"B\" else: return \"\" "
gp.CalculateField_management("INFILE", "OLDFIELD", "codefun(!NEWFIELD!", "PYTHON", codeblock)
I got error:
RuntimeError:
exceptions.SyntaxError: invalid syntax (line 1)
Failed to execute (CalculateField).
Thanks for any kind of help!
Lydia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090409/6a044e73/attachment.html>
More information about the Python-list
mailing list