<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Classify values in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12279#M1000</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanx, my understanding for python is getting better an better, here is the code...it is not running so far...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import arcgisscripting
gp = arcgisscripting.create()


Feature_Class = gp.GetParameterAsText(0) # Location of Geodatabase
classBreaks_str = gp.GetParameterAsText(1) # Break values (comma separated values)
classValues_str = gp.GetParameterAsText(2) # Classes (comma separated values) to be returned, must correspond with the Break values
valueField = gp.GetParameterAsText(3) # Field to be calculated on
classField = gp.GetParameterAsText(4) # Field for results to go in

classBreaks_str = '[' + classBreaks_str + ']' # add square brackets, so they look like lists
classValues_str = '[' + classValues_str + ']'

try: classBreaks = eval(classBreaks_str)
except SyntaxError: arcpy.AddError('Class Breaks was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Breaks was entered incorrectly; values must either be numbers or, if strings, within quotes.')

try: classValues = eval(classValues_str) # I called this classVals in the previous post
except SyntaxError: arcpy.AddError('Class Values was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Values was entered incorrectly; values must either be numbers or, if strings, within quotes.')

if len(classBreaks) != len(classValues):
 arcpy.AddError('Class Values and Class Breaks must be the same length.')

def calc(x): # function that does the calculation
 '''calc(x) iterates through the classBreaks until it finds the bounding values of the input number, then returns the corresponding value from classVals
 '''
 for i in xrange(len(classBreaks)-1):
&amp;nbsp; if classBreaks&lt;I&gt; &amp;lt;= x &amp;lt; classBreaks[i+1]:
&amp;nbsp;&amp;nbsp; return classValuess&lt;I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif x == classBreaks[-1]: # x equals the last value - wouldn't work above, as it is less than...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return classValues[-1]
 return None # return something if the value isn't within the range, can be whatever you want - None will be converted to Arc NULL, but you could have 'No Class' or something like that, if you wanted...


listFCs = arcpy.ListFeatureClasses("*")
for fc in listFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.classField = calc(row.valueField)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

try: del row
except NameError: pass
del rows
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;type 'exceptions.RuntimeError'&amp;gt;: Row: Field valueField does not exist
Failed to execute (Classify)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the Parameter's dialogue, I configured the input as feature class and value- and classfield as field. But if I start the script and choose a fc, it doesnt read out the available columns (fields)? Is the parameter configuration wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I want to loop through several feature classes and I define as input workspace or feature dataset, I have to input the valuefield and classfield names as string. Is this possible by just setting the parameter type of the script properties to string?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:31:29 GMT</pubDate>
    <dc:creator>MatthiasAbele</dc:creator>
    <dc:date>2021-12-10T20:31:29Z</dc:date>
    <item>
      <title>Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12272#M993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hallo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I ve got a column with values between 0 - 2. I would like to classify the values in classes between 1 - 5 according to the following scheme. The class for each value should be written in another column.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 1&amp;nbsp;&amp;nbsp; 0.0 - 0.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 2&amp;nbsp;&amp;nbsp; 0.2 - 0.4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 3&amp;nbsp;&amp;nbsp; 0.4 - 0.6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 4&amp;nbsp;&amp;nbsp; 0.6 - 0.8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 5&amp;nbsp;&amp;nbsp; 0.8 - 1.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 4&amp;nbsp;&amp;nbsp; 1.0 - 1.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 3&amp;nbsp;&amp;nbsp; 1.2 - 1.4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 2&amp;nbsp;&amp;nbsp; 1.4 - 1.6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Class 1&amp;nbsp;&amp;nbsp; 1.6 - 9.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I do this with python for several feature classes?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanx for any hints,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 14:47:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12272#M993</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2011-09-02T14:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12273#M994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could write something similar to the code below.&amp;nbsp; You will probably have to add a try/except clause to pass feature classes that do not contain the corresponding fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"

lstFCs = arcpy.ListFeatureClasses("*")
for fc in lstFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt;= 0.0 and row.Value &amp;lt;= 0.2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 0.2 and row.Value &amp;lt;= 0.4:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 0.4 and row.Value &amp;lt;= 0.6:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 0.6 and row.Value &amp;lt;= 0.8:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 4
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 0.8 and row.Value &amp;lt;= 1.0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 5
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 1.0 and row.Value &amp;lt;= 1.2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 4
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 1.2 and row.Value &amp;lt;= 1.4:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 1.4 and row.Value &amp;lt;= 1.6:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Value &amp;gt; 1.6 and row.Value &amp;lt;= 2.0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Class = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; except RuntimeError:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass

del row, rows&amp;nbsp; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12273#M994</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T20:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12274#M995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Assuming your value field is &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;Value&lt;/STRONG&gt;&lt;SPAN&gt; and your class (output) field is &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;ClassField&lt;/STRONG&gt;&lt;SPAN&gt;. If you are using it in a Field Calculator:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;STRONG&gt;Pre-Logic Script Code:&lt;/STRONG&gt;
classBreaks = [0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 2] # defines where the values for the breaks are
classVals = [1, 2, 3, 4, 5, 4, 3, 2, 1] # what should be returned - corresponds to the position of the value in classBreaks

def calc(x): # function that does the calculation
 '''calc(x) iterates through the classBreaks until it finds the bounding values of the input number, then returns the corresponding value from classVals
 '''
 for i in xrange(len(classBreaks)-1):
&amp;nbsp; if classBreaks&lt;I&gt; &amp;lt;= x &amp;lt; classBreaks[i+1]:
&amp;nbsp;&amp;nbsp; return classVals&lt;I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif x == classBreaks[-1]: # x equals the last value - wouldn't work above, as it is less than...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return classVals[-1]
 return None # return something if the value isn't within the range, can be whatever you want - None will be converted to Arc NULL, but you could have 'No Class' or something like that, if you wanted...

&lt;STRONG&gt;ClassField=&lt;/STRONG&gt;
calc(!Value!)
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or as part of a Python script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

classBreaks = [0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 2] # defines where the values for the breaks are
classVals = [1, 2, 3, 4, 5, 4, 3, 2, 1] # what should be returned - corresponds to the position of the value in classBreaks

def calc(x): # function that does the calculation
 '''calc(x) iterates through the classBreaks until it finds the bounding values of the input number, then returns the corresponding value from classVals
 '''
 for i in xrange(len(classBreaks)-1):
&amp;nbsp; if classBreaks&lt;I&gt; &amp;lt;= x &amp;lt; classBreaks[i+1]:
&amp;nbsp;&amp;nbsp; return classVals&lt;I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif x == classBreaks[-1]: # x equals the last value - wouldn't work above, as it is less than...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return classVals[-1]
 return None # return something if the value isn't within the range, can be whatever you want - None will be converted to Arc NULL, but you could have 'No Class' or something like that, if you wanted...

arcpy.env.workspace = r"C:\temp\python\test.gdb"

listFCs = arcpy.ListFeatureClasses("*")
for fc in listFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.ClassField = calc(row.Value)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del row, rows
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12274#M995</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-10T20:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12275#M996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hallo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanx for the code; worked very good with some test data; but if I apply it to my real data I get the error: Runtime error &amp;lt;type 'exceptions.NameError'&amp;gt;: name 'row' is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What could be the reason? I properly changed the path and the field names...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 15:22:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12275#M996</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2011-09-05T15:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12276#M997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Was it my code or Jakes you were using? Either way, my guess it that it is failing at the very last line - deleting the variables. For some reason in my experience that occasionally has issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try replacing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;del row, rows&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
try: del row
except NameError: pass
del rows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know how you get on.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12276#M997</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-10T20:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12277#M998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi StacyRendall,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it worked now. But I still had problems. The file names of my feature classes were very long and contained some numbers. When I reduced the file name lengths and erased the numbers, it worked. So, thanx a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to make a little script from the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First I would like to define the input geodatabase:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Geodatabase =&amp;nbsp; gp.GetParameterAsText(0) # Location of Geodatabase&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Now, I am a little bit stuck. I would like to read in the class breaks as a comma separated list&lt;BR /&gt;and also the corresponding class values. How is this possible&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I would define the input / calculation row as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;value =&amp;nbsp; gp.GetParameterAsText(3) # Values to be classified&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;classfield = gp.GetParameterAsText(4) # Field to be calculated&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this the right way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2011 14:05:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12277#M998</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2011-09-06T14:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12278#M999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sweet; you are off to a good start. It is actually quite easy to bring in the values as comma separated strings, but you will need to bring the breaks and the break values is as separate parameters. I.e.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# presumably you are bringing in other variables, you only mentioned 0 then jumped to 3 - the parameter numbers must go up in order...
classBreaks_str = gp.GetParameterAsText(3) # Break values (comma separated values)
classValues_str = gp.GetParameterAsText(4) # Classes (comma separated values) to be returned, must correspond with the Break values
valueField = gp.GetParameterAsText(5) # Field to be calculated on
classField = gp.GetParameterAsText(6) # Field for results to go in&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, we will convert them both to look like lists, but stored as strings, then use the Python &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;evaluate&lt;/SPAN&gt;&lt;SPAN&gt; command, &lt;/SPAN&gt;&lt;STRONG&gt;eval()&lt;/STRONG&gt;&lt;SPAN&gt;, to turn them into lists. Eval parses strings and outputs them literally. Continuing on from above:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;classBreaks_str = '[' + classBreaks_str + ']' # add square brackets, so they look like lists
classValues_str = '[' + classValues_str + ']'

try: classBreaks = eval(classBreaks_str)
except SyntaxError: arcpy.AddError('Class Breaks was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Breaks was entered incorrectly; values must either be numbers or, if strings, within quotes.')

try: classValues = eval(classValues_str) # I called this classVals in the previous post
except SyntaxError: arcpy.AddError('Class Values was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Values was entered incorrectly; values must either be numbers or, if strings, within quotes.')

if len(classBreaks) != len(classValues):
 arcpy.AddError('Class Values and Class Breaks must be the same length.')
 
# rest of processing (previous posts) goes here...
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The classValues is classVals from my previous post, but classBreaks is the same... I also added a few things to catch common errors; they will cause an Arcpy Error to appear in the processing results window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know how you get on.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12278#M999</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-10T20:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12279#M1000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanx, my understanding for python is getting better an better, here is the code...it is not running so far...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import arcgisscripting
gp = arcgisscripting.create()


Feature_Class = gp.GetParameterAsText(0) # Location of Geodatabase
classBreaks_str = gp.GetParameterAsText(1) # Break values (comma separated values)
classValues_str = gp.GetParameterAsText(2) # Classes (comma separated values) to be returned, must correspond with the Break values
valueField = gp.GetParameterAsText(3) # Field to be calculated on
classField = gp.GetParameterAsText(4) # Field for results to go in

classBreaks_str = '[' + classBreaks_str + ']' # add square brackets, so they look like lists
classValues_str = '[' + classValues_str + ']'

try: classBreaks = eval(classBreaks_str)
except SyntaxError: arcpy.AddError('Class Breaks was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Breaks was entered incorrectly; values must either be numbers or, if strings, within quotes.')

try: classValues = eval(classValues_str) # I called this classVals in the previous post
except SyntaxError: arcpy.AddError('Class Values was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Values was entered incorrectly; values must either be numbers or, if strings, within quotes.')

if len(classBreaks) != len(classValues):
 arcpy.AddError('Class Values and Class Breaks must be the same length.')

def calc(x): # function that does the calculation
 '''calc(x) iterates through the classBreaks until it finds the bounding values of the input number, then returns the corresponding value from classVals
 '''
 for i in xrange(len(classBreaks)-1):
&amp;nbsp; if classBreaks&lt;I&gt; &amp;lt;= x &amp;lt; classBreaks[i+1]:
&amp;nbsp;&amp;nbsp; return classValuess&lt;I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif x == classBreaks[-1]: # x equals the last value - wouldn't work above, as it is less than...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return classValues[-1]
 return None # return something if the value isn't within the range, can be whatever you want - None will be converted to Arc NULL, but you could have 'No Class' or something like that, if you wanted...


listFCs = arcpy.ListFeatureClasses("*")
for fc in listFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.classField = calc(row.valueField)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

try: del row
except NameError: pass
del rows
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;type 'exceptions.RuntimeError'&amp;gt;: Row: Field valueField does not exist
Failed to execute (Classify)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the Parameter's dialogue, I configured the input as feature class and value- and classfield as field. But if I start the script and choose a fc, it doesnt read out the available columns (fields)? Is the parameter configuration wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I want to loop through several feature classes and I define as input workspace or feature dataset, I have to input the valuefield and classfield names as string. Is this possible by just setting the parameter type of the script properties to string?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12279#M1000</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2021-12-10T20:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12280#M1001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, Arc can list the field types, it is just a little tricky. When you set the parameters, for the field parameter you need to set the &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;Filter &lt;/STRONG&gt;&lt;SPAN&gt;to &lt;/SPAN&gt;&lt;STRONG&gt;field &lt;/STRONG&gt;&lt;SPAN&gt;and the&lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt; Obtained from&lt;/STRONG&gt;&lt;SPAN&gt; as the parameter name you gave to your layer. As long as you select your layer before finding the field, it should work fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is one other thing I missed that will still cause it to fail. When using a cursor there are two ways you can access a value in a field; either &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;row.getValue('fieldname')&lt;/SPAN&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;row.fieldname&lt;/SPAN&gt;&lt;SPAN&gt;. The problem with the latter method is that your field name has to be hard-coded - so you can't easily make it an input parameter. There is a similar distinction when setting the value of a field; either &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;row.setValue('fieldname', value)&lt;/SPAN&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;row.fieldname = value&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Some other things:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;you don't need to import &lt;STRONG&gt;arcgisscripting&lt;/STRONG&gt; or worry about the &lt;STRONG&gt;gp&lt;/STRONG&gt; bits - that was Arc 9 stuff.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;you need to list your feature classes based on the Geodatabase location, by setting the environment workspace to the geodatabase.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;the del row and rows statements need to be within the feature class iterator (i.e. indented), as you want to clear them out once you are done with each feature class.&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty sure that this now should work just fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

def calc(x): # function that does the calculation
 '''calc(x) iterates through the classBreaks until it finds the bounding values of the input number, then returns the corresponding value from classVals
 '''
 for i in xrange(len(classBreaks)-1):
&amp;nbsp; if classBreaks&lt;I&gt; &amp;lt;= x &amp;lt; classBreaks[i+1]:
&amp;nbsp;&amp;nbsp; return classValues&lt;I&gt;
&amp;nbsp; elif x == classBreaks[-1]: # x equals the last value - wouldn't work above, as it is less than...
&amp;nbsp;&amp;nbsp; return classValues[-1]
 return None # return something if the value isn't within the range, can be whatever you want - None will be converted to Arc NULL, but you could have 'No Class' or something like that, if you wanted...

Geodatabase = arcpy.GetParameterAsText(0) # Location of Geodatabase
classBreaks_str = arcpy.GetParameterAsText(1) # Break values (comma separated values)
classValues_str = arcpy.GetParameterAsText(2) # Classes (comma separated values) to be returned, must correspond with the Break values
valueField = arcpy.GetParameterAsText(3) # Field to be calculated on
classField = arcpy.GetParameterAsText(4) # Field for results to go in

classBreaks_str = '[' + classBreaks_str + ']' # add square brackets, so they look like lists
classValues_str = '[' + classValues_str + ']'

try: classBreaks = eval(classBreaks_str)
except SyntaxError: arcpy.AddError('Class Breaks was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Breaks was entered incorrectly; values must either be numbers or, if strings, within quotes.')

try: classValues = eval(classValues_str)
except SyntaxError: arcpy.AddError('Class Values was entered incorrectly; values must each seperated by a comma.')
except NameError: arcpy.AddError('Class Values was entered incorrectly; values must either be numbers or, if strings, within quotes.')

if len(classBreaks) != len(classValues):
 arcpy.AddError('Class Values and Class Breaks must be the same length.')

arcpy.env.workspace = Geodatabase # set the workspace

listFCs = arcpy.ListFeatureClasses('*')
for fc in listFCs:
 rows = arcpy.UpdateCursor(fc)
 for row in rows:
&amp;nbsp; row.setValue(classField, calc(row.getValue(valueField))) # looks complex, but is just getting the value from valueField, passing it to CALC then writing the output to the classField
&amp;nbsp; rows.updateRow(row)

 try: del row
 except NameError: pass
 del rows&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12280#M1001</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-10T20:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12281#M1002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi StacyRendall,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you a lot for the hints...I was able to make the scirpt work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 13:53:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12281#M1002</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2011-09-21T13:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12282#M1003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi StacyRendall,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;two things I have recognized:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- the class breaks must contain a last element, which is the upper limit of all values, and so have one element more than the class values. Your code checks if both are equal; if not it interrupts the script...so I changed it to and it is working....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if len(classBreaks)- 1 != len(classValues):
 arcpy.AddError('Class Values and Class Breaks must be the same length.')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- if I choose a geodatabase or feature dataset and there a features inside which do have the value field but not the class field, the code stops.(also for those which have both fields) If I delete those with only a value field, the code works again. What could be the reason?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12282#M1003</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2021-12-10T20:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12283#M1004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Matthias,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good spotting on the first point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure what you mean on the second one. Every feature class in your workspace needs to have both fields, or else it will fail.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2011 21:21:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12283#M1004</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-09-26T21:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12284#M1005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi StacyRendall,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;why does every feature in the gdb must have both fields? Is it possible to configure it in a way, so that it just scips features which do not have to given fields?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2011 10:19:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12284#M1005</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2011-09-27T10:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Classify values</title>
      <link>https://community.esri.com/t5/python-questions/classify-values/m-p/12285#M1006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sure, with ListFields() and then a conditional to check if the field is actually in the feature class...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change the last bit of code (from &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;for fc in listFCs&lt;/SPAN&gt;&lt;SPAN&gt; onwards):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for fc in listFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcFieldList = arcpy.ListFields(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (valueField in fcFieldList) &amp;amp; (classField in fcFieldList):
&amp;nbsp; rows = arcpy.UpdateCursor(fc)
&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp; row.setValue(classField, calc(row.getValue(valueField))) # looks complex, but is just getting the value from valueField, passing it to CALC then writing the output to the classField
&amp;nbsp;&amp;nbsp; rows.updateRow(row)

&amp;nbsp; try: del row
&amp;nbsp; except NameError: pass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the feature class doesn't have both fields, it will skip the file. It would also be possible to add the fields, if that was what you wanted.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/classify-values/m-p/12285#M1006</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-10T20:31:37Z</dc:date>
    </item>
  </channel>
</rss>

