<?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: Calculate Field VB to Python in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264914#M26748</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChristianRowe_0-1678197516963.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64536i95812FDE84920902/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChristianRowe_0-1678197516963.png" alt="ChristianRowe_0-1678197516963.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You helped get me closer but now I'm getting this error, any tips?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a ton.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 13:59:12 GMT</pubDate>
    <dc:creator>ChristianRowe</dc:creator>
    <dc:date>2023-03-07T13:59:12Z</dc:date>
    <item>
      <title>Calculate Field VB to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264712#M26746</link>
      <description>&lt;P&gt;I have a VB script used for caluculating field data, but need it in Python. Here is the VB Script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim a&lt;/P&gt;&lt;P&gt;If ( [DA_LU_SOIL.SOIL] ="B") Then&lt;/P&gt;&lt;P&gt;a= [CN_Reference.B]&lt;/P&gt;&lt;P&gt;elseif ( [DA_LU_SOIL.SOIL] ="C") Then&lt;/P&gt;&lt;P&gt;a= [CN_Reference.C]&lt;/P&gt;&lt;P&gt;elseif ( [DA_LU_SOIL.SOIL] ="D") Then&lt;/P&gt;&lt;P&gt;a= [CN_Reference.D]&lt;/P&gt;&lt;P&gt;end if&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 20:42:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264712#M26746</guid>
      <dc:creator>ChristianRowe</dc:creator>
      <dc:date>2023-03-06T20:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field VB to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264717#M26747</link>
      <description>&lt;P&gt;Here are two ways- not sure what your fields are so replace them as needed:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if DA_LU_SOIL.SOIL =="B":
    a = CN_Reference.B
elif DA_LU_SOIL.SOIL == "C":
    a = CN_Reference.C
elif DA_LU_SOIL.SOIL == "D":
    a = CN_Reference.D
# or

valDict = {"B": CN_Reference.B,
           "C": CN_Reference.C,
           "D": CN_Reference.D}

a = valDict.get(DA_LU_SOIL.SOIL)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 Mar 2023 21:13:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264717#M26747</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-03-06T21:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field VB to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264914#M26748</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChristianRowe_0-1678197516963.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64536i95812FDE84920902/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChristianRowe_0-1678197516963.png" alt="ChristianRowe_0-1678197516963.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You helped get me closer but now I'm getting this error, any tips?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a ton.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 13:59:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264914#M26748</guid>
      <dc:creator>ChristianRowe</dc:creator>
      <dc:date>2023-03-07T13:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field VB to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264961#M26749</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm" target="_blank" rel="noopener"&gt;calculate-field-examples&lt;/A&gt; - Check out the Calculate fields using logic section.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first block (expression) you need to call the function that you define in the Code Block.&lt;/P&gt;&lt;P&gt;SoilsUnion.CN =&lt;/P&gt;&lt;LI-CODE lang="python"&gt;calcfunction(!Soils.Union3_HSG!, !CN_Reference.A!, !CN_Reference.B!, !CN_Reference.C!, !CN_Reference.D!)&lt;/LI-CODE&gt;&lt;P&gt;(you may need to remove the !.&amp;nbsp; Easiest way is to just double click on the field and Pro will put it in the argument with the right decoration.)&lt;/P&gt;&lt;P&gt;Code Block:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def calcfunction(checkField, refA, refB, refC, refD):
    if checkField =="A":
        return refA
    elif checkField =="B":
        return refB
    elif checkField == "C":
        return refC
    elif checkField == "D":
        return refD&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 15:59:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-field-vb-to-python/m-p/1264961#M26749</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-03-07T15:59:03Z</dc:date>
    </item>
  </channel>
</rss>

