I have a table with a column named "Kategorie", filled with values. I added a new column named "RULE". I want to fill this column with Strings depending on "KATEGORIE". I have a PY-Script and it doesn't work.
What is wrong?
Expression:
"getKat(!KATEGORIE!)"
Codeblock:
"""def getKat(KATEGORIE):
if KATEGORIE = "0":
myval = "Autobahn"
if KATEGORIE = "1":
myval = "Bundesstrasse"
else:
myval= 3"""
arcpy.CalculateField_management(ERG, "RULE", expression, "", codeblock)
Both answers so far don't work. I think the problem is the line "expression" or "codeblock". I try to print the result of "myval".The result is a error message "name myval is not defined"
expression:
"getKat(!KATEGORIE!)"
codeblock:
"""def getKat(KATEGORIE):
if KATEGORIE == "0":
myval == "Autobahn"
elif KATEGORIE == "1":
myval == "Bundesstrasse"
else:
myval == "3"
return myval"""
print "myval", myval
arcpy.CalculateField_management(ERG, "RULE", expression, "PYTHON", codeblock)
No comments:
Post a Comment