<?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: Using a dictionary or list with an Insert Cursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215231#M16593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;He could just change up row_values:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;row_values &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;k&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;v &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; k&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;v &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; d&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Sep 2019 19:29:34 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-09-24T19:29:34Z</dc:date>
    <item>
      <title>Using a dictionary or list with an Insert Cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215227#M16589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In &lt;A _jive_internal="true" href="https://community.esri.com/thread/240737-would-like-to-improve-performance" target="_blank"&gt;this thread&lt;/A&gt;, I am creating a dictionary with which to use with an InsertCursor to add rows to an existing table. I can get the dictionary created okay, but I keep getting an error when I try to use it as the data source:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;File "&amp;lt;ipython-input-4-ce36707b33ba&amp;gt;", line 3, in &amp;lt;module&amp;gt;&lt;BR /&gt; cursor.insertRow(row)&lt;/P&gt;&lt;P&gt;TypeError: sequence size must match size of the row&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In &lt;A _jive_internal="true" href="https://community.esri.com/thread/222389-insert-cursor-to-iterate-through-dictionary" target="_blank"&gt;another thread&lt;/A&gt;, &lt;A href="https://community.esri.com/migrated-users/34565" target="_blank"&gt;Randy Burton&lt;/A&gt;&amp;nbsp;suggests iterating though a dictionary so I'm attempting to follow his lead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My dictionary looks like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'16304760420000'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1536639.422987029&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7422834.91819194&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
 &lt;SPAN class="string token"&gt;'16304760430000'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1536594.1241931021&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7422763.591562942&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
 &lt;SPAN class="string token"&gt;'16304760440000'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1536511.8395807743&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7422768.880266264&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
 &lt;SPAN class="string token"&gt;'16304760450000'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1536457.3127869368&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7422770.376654357&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I fiddled around a bit with the dictionary itself,&amp;nbsp;but didn't get too far, so after taking another look at the &lt;A href="http://desktop.arcgis.com/en/arcmap/10.6/analyze/arcpy-data-access/insertcursor-class.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;online help for InsertCursors&lt;/A&gt;, I turn the dictionary into a list and tried that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;bucket &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'J:\PythonDevelopment\ParcelsXY_Mojo\ParcelsMojo.gdb\LocalSlcoDept_ParcelsXY'&lt;/SPAN&gt; 
bucketFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'parcel_id'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'XCOORD'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'YCOORD'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

row_values &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;myDictionary&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

cursor &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;InsertCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;bucket&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;bucketFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; row_values&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;    
    cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;insertRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I think my problem with this is the help page describes using the row_values list to insert a @SHAPE, but I just want to insert a row in a table where row[0] us the parcel_id, row[1][0] is the XCOORD and row[1][1] is the YCOORD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I translate myDictionary key:(value1,value2) or&amp;nbsp; my row_values items into a form that the InsertCursor can handle?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:32:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215227#M16589</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T10:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using a dictionary or list with an Insert Cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215228#M16590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This part of the error message is most telling:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;TypeError: sequence size must match size of the row&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It is saying you are passing a sequence (list, tuple, etc...) with the wrong number of elements to the cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at your code, your cursor has 3 fields but your dictionary contains items with only 2 items per tuple.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2019 18:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215228#M16590</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-09-24T18:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using a dictionary or list with an Insert Cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215229#M16591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might try:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;d = {'16304760420000': (1536639.422987029, 7422834.91819194),
 '16304760430000': (1536594.1241931021, 7422763.591562942),
 '16304760440000': (1536511.8395807743, 7422768.880266264),
 '16304760450000': (1536457.3127869368, 7422770.376654357)}

for k in d.keys(): # something like this for lines 7-8 in your code
	print k, d&lt;K&gt;[0], d&lt;K&gt;[1] # parcel_id, X, Y‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/K&gt;&lt;/K&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:32:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215229#M16591</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T10:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using a dictionary or list with an Insert Cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215230#M16592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Randy-&amp;nbsp; I'll give it a spin.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2019 19:27:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215230#M16592</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-09-24T19:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a dictionary or list with an Insert Cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215231#M16593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;He could just change up row_values:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;row_values &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;k&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;v &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; k&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;v &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; d&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2019 19:29:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215231#M16593</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-09-24T19:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using a dictionary or list with an Insert Cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215232#M16594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now I have a couple of options.&amp;nbsp; Thanks Joshua!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2019 19:30:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-dictionary-or-list-with-an-insert-cursor/m-p/215232#M16594</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-09-24T19:30:24Z</dc:date>
    </item>
  </channel>
</rss>

