<?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: Field calculation issues in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-issues/m-p/1076473#M25660</link>
    <description>&lt;P&gt;are you doing this in arcmap or arcgis pro? (because&amp;nbsp;&lt;SPAN&gt;PYTHON3 is used in Pro)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think you missed codeblock.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, you don't need to return None and you can format your codeblock as&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Category = "StructureCategory"
expression5 = "Reclass(!StructureT!)"
codeblock = """
def Reclass (newdams_schema):
    if 'Diversion' in newdams_schema:
        return 3
    elif 'Dam' in newdams_schema:
        return 9
    else:
        return
"""
arcpy.management.CalculateField(newdams_schema,
                                field=Category,
                                expression=expression5,
                                expression_type="PYTHON",
                                code_block=codeblock)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jul 2021 20:29:30 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-07-07T20:29:30Z</dc:date>
    <item>
      <title>Field calculation issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-issues/m-p/1076427#M25659</link>
      <description>&lt;P&gt;I'm trying to calculate a field from another field using arcpy. If the field contains the word Diversion, I want it to calculate the other field with the value 3. If it conctains 'Dam' I want it to calculate 9, otherwise keep it null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to execute this in the python window, itlooks like it's working, but my field is still null. The new field is a long integer. Please Help!&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Category = "StructureCategory"
expression5 = "Reclass(!StructureT!)"
codeblock = """def Reclass (newdams_schema):
    if 'Diversion' in newdams_schema:
        return 3
    elif 'Dam' in newdams_schema:
        return 9
    else:
        return None"""

# Execute CalculateField 
arcpy.CalculateField_management(newdams_schema, Category, expression5, "PYTHON_9.3")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 19:00:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculation-issues/m-p/1076427#M25659</guid>
      <dc:creator>KatHoenke</dc:creator>
      <dc:date>2021-07-07T19:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-issues/m-p/1076473#M25660</link>
      <description>&lt;P&gt;are you doing this in arcmap or arcgis pro? (because&amp;nbsp;&lt;SPAN&gt;PYTHON3 is used in Pro)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think you missed codeblock.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, you don't need to return None and you can format your codeblock as&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Category = "StructureCategory"
expression5 = "Reclass(!StructureT!)"
codeblock = """
def Reclass (newdams_schema):
    if 'Diversion' in newdams_schema:
        return 3
    elif 'Dam' in newdams_schema:
        return 9
    else:
        return
"""
arcpy.management.CalculateField(newdams_schema,
                                field=Category,
                                expression=expression5,
                                expression_type="PYTHON",
                                code_block=codeblock)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 20:29:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculation-issues/m-p/1076473#M25660</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-07-07T20:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-issues/m-p/1076540#M25661</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 22:56:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculation-issues/m-p/1076540#M25661</guid>
      <dc:creator>KatHoenke</dc:creator>
      <dc:date>2021-07-07T22:56:41Z</dc:date>
    </item>
  </channel>
</rss>

