<?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 Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-field-error/m-p/387768#M30647</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem is that in VB you need to wrap strings in quotes. When you pass what you've written into the field calculator from Python, it strips off the quotes of the parameters turning "STAK" into STAK. Basically, you just need an extra set of quotes around the expression so it's left with quotes once the first set have been stripped.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.CalculateField_management ("WELL_PT", "W_STATUS", ' "STAK" ', "VB")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jun 2012 14:15:15 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2012-06-26T14:15:15Z</dc:date>
    <item>
      <title>Calculate Field Error</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-error/m-p/387767#M30646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is most likely a simple question but I just cant seam to lick it. I have this code that I want to calculate a field for me. the field is &lt;/SPAN&gt;&lt;STRONG&gt;STRING, 8 Characters.&lt;/STRONG&gt;&lt;SPAN&gt; There is a domain on this field with some coded values. I exported a dbf of the feature to confirm the value should be STAK. Every time I run this bad boy I get the attached error. I have tried both VB and PYTHON code but nothing seems to work (although the error reporting from python looks better). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have a feeling that there is one simple thing I'm not doing, can someone please help?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Workspace will be the database for export&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = r"P:\folder\rmp_2_5_2.mdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#calculate fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateField_management ("WELL_PT", "W_STATUS", "STAK", "VB")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]15481[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The calculated value is invalid for the row with ObjectID=2011. 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;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 12:47:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-error/m-p/387767#M30646</guid>
      <dc:creator>davidmetzler</dc:creator>
      <dc:date>2012-06-26T12:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Error</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-error/m-p/387768#M30647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem is that in VB you need to wrap strings in quotes. When you pass what you've written into the field calculator from Python, it strips off the quotes of the parameters turning "STAK" into STAK. Basically, you just need an extra set of quotes around the expression so it's left with quotes once the first set have been stripped.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.CalculateField_management ("WELL_PT", "W_STATUS", ' "STAK" ', "VB")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 14:15:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-error/m-p/387768#M30647</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-06-26T14:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Error</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field-error/m-p/387769#M30648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much. This worked like a charm. here is the final code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Workspace will be the database for export&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = r"P:\folder\rmp_2_5_2.mdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#calculate fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateField_management ("WELL_PT", "W_STATUS", ' "STAK" ', "VB")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Happy GISing,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Dave&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 15:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field-error/m-p/387769#M30648</guid>
      <dc:creator>davidmetzler</dc:creator>
      <dc:date>2012-06-26T15:56:10Z</dc:date>
    </item>
  </channel>
</rss>

