AnsweredAssumed Answered

Need help with a calculate Python Print Statement script for ArcMap

Question asked by Locklin on Nov 5, 2016
Latest reply on Nov 5, 2016 by bixb0012

To finish off my script tool i want the script to give me an add message (sum) that calculates total hectares for only 2 certain attributes (soil classes 1 and 2) in my Hectares field. I have a hectares field and a field that give soil classes 1 to 5. in the python language how would i write the expression?


The shapefile i want to perform this on is called: [clip_output]  

The field thats lists soil type is called: [CLASS]    

The hectares field that I want the script to give me the sum from is called [Hectares]  


This is what I have so far but it is not working (not sure if i need to list variables):


with arcpy.da.SearchCursor(clip_output, ['Hectares'], 'CLASS in (1, 2)') as cur:
   sum = 0
   for row in cur:
      sum += row[0]



error im getting is: 

line 106, in <module> for row in cur: RuntimeError: An invalid SQL statement was used