Code works on ArcMap "Field Calculator..." when I click on attribute and calculate.
But if does not work in ModelBuilder calculate field tool.
Any ideas?
Pre-Logic Script Code:
def ifBlock(Country):
if Country == 'China':
return "A"
elif Country == 'Canada':
return "B"
elif Country == 'Russia':
return "C"
result=
ifBlock(!Country!)
Vince
20.5k16 gold badges49 silver badges65 bronze badges
-
1also, did you check your indentations (this is maybe just due to the layout, but indentations are not correct in your postradouxju– radouxju2017年08月17日 08:29:59 +00:00Commented Aug 17, 2017 at 8:29
-
Text field comparison to fill another (text) field. error I get is "ERROR 000539: SyntaxError: invalid syntax (<expression>, line 1) Failed to execute (Calculate Field (3))."Rafael– Rafael2017年08月17日 08:31:07 +00:00Commented Aug 17, 2017 at 8:31
-
1The code above looks fine. Make sure you've selected "PYTHON" as the expression type.MacroZED– MacroZED2017年08月17日 08:33:06 +00:00Commented Aug 17, 2017 at 8:33
-
I know code is ok, cos its works in field calculator, but not in modelbuilder calculate field tool. I knew there are differences how modelbuilder responds, but this is annoyingRafael– Rafael2017年08月17日 08:35:18 +00:00Commented Aug 17, 2017 at 8:35
-
1Could you add a screenshot showing your model and the settings of the Calculate Field tool?Bera– Bera2017年08月17日 09:18:50 +00:00Commented Aug 17, 2017 at 9:18
1 Answer 1
found the problem. i had : behind my result, like this:
result=
ifBlock(!Country!): <--
I have removed it and now it works fine, thanks all!!!
Explore related questions
See similar questions with these tags.
lang-py