<?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 using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106878#M8270</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually just fixed it while tinkering. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed the expression type to "PYTHON" and added single quotes around the region variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Correct code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Calculate Region

# Set local variables
inTable = fiberFeatures
inField = "ProjectRegion"
expression = 'region'

# Execute CalculateField
arcpy.CalculateField_management(inTable, inField, expression, "PYTHON")

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been stuck on this error for over an hour.&amp;nbsp; I would finally decide to ask on here and then figure it out right away &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for responding, though!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:29:24 GMT</pubDate>
    <dc:creator>CoyPotts1</dc:creator>
    <dc:date>2021-12-11T06:29:24Z</dc:date>
    <item>
      <title>Calculate Field using Python</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106874#M8266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to calculate a field based on derived values within a python script.&amp;nbsp; I keep getting the following error, though:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Empty value for ObjectID = 3005&lt;/P&gt;&lt;P&gt;The calculated value is invalid for the row with ObjectID = 3005. For example, the calculated value may be too large for the field or you may be trying to add a string to a number field. This row will not be updated."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script runs through every single feature and returns an error message identical to the one above for each feature. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Calculate Region

# Set local variables
inTable = fiberFeatures
inField = "ProjectRegion"
expression = region

# Execute CalculateField
arcpy.CalculateField_management(inTable, inField, expression, "VB")

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All variables check out just fine when I print them in the ArcMap Python window, and the field within my feature class is of text type.&amp;nbsp; The region is a simple two letter code such as "NC", "NE", "SW", etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried with various combinations of alternatives, such as adding single/double quotes around region, I've added single/double/triple quotes around expression within the CalculateField function, and I've tried entering the variable straight into the function.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only help I can find through internet searches that pertains exactly to what I'm doing is &lt;A _jive_internal="true" href="https://community.esri.com/thread/99287" target="_blank"&gt;HERE&lt;/A&gt;, but it is a little different and I'm not sure how to make it apply to my situation.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on a Windows 7 machine and I'm running ArcGIS Standard version 10.3.0.4322&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106874#M8266</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-11T06:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field using Python</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106875#M8267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your doing a vb calculation. I think you need to change&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;expression = region&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;to &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6; color: #000000; font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif;"&gt;expression = "region"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jun 2015 18:42:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106875#M8267</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-06-16T18:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field using Python</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106876#M8268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response, but that results in the same error message.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jun 2015 18:46:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106876#M8268</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-06-16T18:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field using Python</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106877#M8269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are the properties of your field&lt;/P&gt;&lt;P&gt;Is it a string?&lt;/P&gt;&lt;P&gt;Does it have enough length &amp;gt; 6?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jun 2015 18:50:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106877#M8269</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-06-16T18:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field using Python</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106878#M8270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually just fixed it while tinkering. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed the expression type to "PYTHON" and added single quotes around the region variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Correct code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Calculate Region

# Set local variables
inTable = fiberFeatures
inField = "ProjectRegion"
expression = 'region'

# Execute CalculateField
arcpy.CalculateField_management(inTable, inField, expression, "PYTHON")

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been stuck on this error for over an hour.&amp;nbsp; I would finally decide to ask on here and then figure it out right away &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for responding, though!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:29:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-using-python/m-p/106878#M8270</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-11T06:29:24Z</dc:date>
    </item>
  </channel>
</rss>

