<?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: UpdateCursor - sequence size? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714926#M55492</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think using the list or tuple function in the way described here will yield the desired result.&amp;nbsp; In the original code snippet, I understand MyAttribute to be a single field/attribute, and that the goal is to populate that attribute with "ALL" or some other multi-character string.&amp;nbsp; Since a multi-character string is iterable, passing MyValue to the tuple function will result in a tuple with multiple single-character items instead of a tuple with a single multi-character items, as demonstrated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The suggestion by &lt;A href="https://community.esri.com/migrated-users/5945"&gt;Dallas Shearer&lt;/A&gt;‌ works since it passes the update cursor a single item multi-character tuple, which is what I think the OP is after.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2014 01:20:24 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2014-10-30T01:20:24Z</dc:date>
    <item>
      <title>UpdateCursor - sequence size?</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714923#M55489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to use UpdateCursor to insert some text into an attribute.&amp;nbsp; The attribute is a text field ten characters in length.&amp;nbsp; However the script will only work for values of one character in length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e. if MyValue = "A" the script works&lt;/P&gt;&lt;P&gt;but if MyValue = "All" the error says 'sequence size must match size of the row'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14145966772369091 jive_text_macro" jivemacro_uid="_14145966772369091"&gt;
&lt;P&gt;with arcpy.da.UpdateCursor(MyFeatureLyr, MyAttribute) as cursor:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(MyValue)&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 15:32:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714923#M55489</guid>
      <dc:creator>BenLeslie1</dc:creator>
      <dc:date>2014-10-29T15:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor - sequence size?</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714924#M55490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the updateRow needs to be sent a tupple even if it's only one variable being sent.&lt;/P&gt;&lt;P&gt;change the updaterow to this and it should work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;cursor.updateRow((MyValue,)) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 20:59:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714924#M55490</guid>
      <dc:creator>DallasShearer</dc:creator>
      <dc:date>2014-10-29T20:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor - sequence size?</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714925#M55491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The help files says lists or tuples can be used for parameters that require them, see &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000014000000"&gt;da.UpdateCursor help&lt;/A&gt;&amp;nbsp;&amp;nbsp; if so, I would do it explicitly using the list and tuple methods&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a= list('astring')&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a&lt;/P&gt;&lt;P&gt;['a', 's', 't', 'r', 'i', 'n', 'g']&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; b = tuple('astring')&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; b&lt;/P&gt;&lt;P&gt;('a', 's', 't', 'r', 'i', 'n', 'g')&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or in your case list(MyValue) or tuple(MyValue) in the appropriate line(s)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 21:37:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714925#M55491</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-10-29T21:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor - sequence size?</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714926#M55492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think using the list or tuple function in the way described here will yield the desired result.&amp;nbsp; In the original code snippet, I understand MyAttribute to be a single field/attribute, and that the goal is to populate that attribute with "ALL" or some other multi-character string.&amp;nbsp; Since a multi-character string is iterable, passing MyValue to the tuple function will result in a tuple with multiple single-character items instead of a tuple with a single multi-character items, as demonstrated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The suggestion by &lt;A href="https://community.esri.com/migrated-users/5945"&gt;Dallas Shearer&lt;/A&gt;‌ works since it passes the update cursor a single item multi-character tuple, which is what I think the OP is after.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 01:20:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714926#M55492</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2014-10-30T01:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor - sequence size?</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714927#M55493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree...I guess my point wasn't clear...sorry... &lt;BR /&gt;Manually create the tuple from a string, requires entering the , directly&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = ("astring",)&amp;nbsp; # create the tuple directly&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a&lt;/P&gt;&lt;P&gt;('astring',)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have a list of string already&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = ["astring"]&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; b = tuple(a)&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; b&lt;/P&gt;&lt;P&gt;('astring',)&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;If you just have a string, in either case of the tuple or list, you still have to add the string to it otherwise the string is treated as the iterable&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 10:28:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-sequence-size/m-p/714927#M55493</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-10-30T10:28:47Z</dc:date>
    </item>
  </channel>
</rss>

