AnsweredAssumed Answered

Help with Calculate Field Management

Question asked by Xhosa on Nov 14, 2013
Latest reply on Nov 18, 2013 by SWalbridge-esristaff
I have this code setup properly (or so I think...) but get ERROR 000989. It would indicate that my syntax in the expression and/or codeblock is incorrect but it works within Arcmap on a single field. I am unsure how to fix this, any help would be greatly appreciated. Thanks!

import arcpy import os, math from arcpy import env  in_workspace = r"C:/" fieldName = "Symbology" expression = "Popclass(!Abbr!)" codeblock = "def Popclass(City):\     if MKE in City:\         return 1\     elif Madison in City:\         return 2\     elif Eau Claire in City:\         return 3\     else:\         return 0" for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="FeatureClass",type="All"):     if "skipFolder" in dirnames:     for filename in filenames:         if "Abbr" in [f.name for f in arcpy.ListFields(os.path.join(dirpath, filename))]:             arcpy.AddField_management(os.path.join(dirpath,filename), fieldName, "SHORT", "", "", "", "", "NULLABLE")             arcpy.CalculateField_management(os.path.join(dirpath,filename), "Symbology", expression, "PYTHON", codeblock)         else:             print "no Abbr field for dataset ", filename print "message that reflected field calc use" print "Finished script"    

Outcomes