<?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: loop terminates in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477414#M37371</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sounds like nested cursor issues.&lt;/P&gt;&lt;P&gt;Don't you cursor types use 'while' loops? or do you have to call a next()?&amp;nbsp; I am sure the others have examples, but&lt;STRONG&gt; &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/searchcursor-class.htm"&gt;here is the docs&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt; If it data were not in the millions of records, I would just read both into arrays/lists, do the comparisons and keep an index of what to change for processing after, rather than on the go&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Sep 2017 13:17:08 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2017-09-21T13:17:08Z</dc:date>
    <item>
      <title>loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477412#M37369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to perform some editing&amp;nbsp;on features that have the same attribute value&amp;nbsp; as features of a different feature class. So I tried this:&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;field0 = 'SKMS_tor'&lt;BR /&gt;field1 = 'SKMS'&lt;BR /&gt;cursor0 = arcpy.da.SearchCursor(fc0, field0)&lt;BR /&gt;cursor1 = arcpy.da.SearchCursor(fc1, field1)&lt;/P&gt;&lt;P&gt;for row0 in cursor0:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row1 in cursor1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if row0 == row1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do do editing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;skip editing&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I works, but only for the first round. Then it stops and does not proceed to the second feature in the feature class. Not sure what is wrong with this script.&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested the same syntax on a different example:&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;q = ['a1', 'a2', 'a3']&lt;BR /&gt;w = ['a3', 'a1', 'b2']&lt;BR /&gt;for x in q:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for y in w:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if x == y:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x, " YES ", y&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x, " NO ", y&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it works fine.&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To my novice eye there is no difference in both scripts except the use arcpy.da.SearchCursor(). Can this be a problem? if not, what else?&lt;/P&gt;&lt;P style="padding: 0px; min-height: 8pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 10:28:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477412#M37369</guid>
      <dc:creator>TomaszChojnacki</dc:creator>
      <dc:date>2017-09-21T10:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477413#M37370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't have an answer for you Tomasz, but I do have a question; which of the cursors stop? &amp;nbsp;Cursor0 or Cursor1? &amp;nbsp;Just yesterday I was faced with a similar problem where I want to edit one table based on it's interaction with another feature class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's call in the guys that have helped me in the not so distant past with cursors:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/curtvprice"&gt;curtvprice&lt;/A&gt;‌, &lt;A href="https://community.esri.com/people/dkwiens"&gt;dkwiens&lt;/A&gt;‌, &lt;A href="https://community.esri.com/people/Dan_Patterson"&gt;Dan_Patterson&lt;/A&gt;‌, &lt;A href="https://community.esri.com/people/jskinner-esristaff"&gt;jskinner-esristaff&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and see what they might say....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 13:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477413#M37370</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2017-09-21T13:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477414#M37371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sounds like nested cursor issues.&lt;/P&gt;&lt;P&gt;Don't you cursor types use 'while' loops? or do you have to call a next()?&amp;nbsp; I am sure the others have examples, but&lt;STRONG&gt; &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/searchcursor-class.htm"&gt;here is the docs&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt; If it data were not in the millions of records, I would just read both into arrays/lists, do the comparisons and keep an index of what to change for processing after, rather than on the go&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 13:17:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477414#M37371</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-09-21T13:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477415#M37372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Overall, the approach is not very efficient, but I only have time now to speak to the specific error you are seeing.&amp;nbsp; You need to reset cursor1 before going to the next row of cursor0.&amp;nbsp; I don't know what is entailed in "do do editing," but you won't be able to do any updates to either data set using search cursors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 13:37:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477415#M37372</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-09-21T13:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477416#M37373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/19932"&gt;Darren Wiens&lt;/A&gt;‌ provided this link yesterday:&amp;nbsp;&amp;nbsp;&lt;A href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries"&gt;/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm about to get into it....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 13:59:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477416#M37373</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2017-09-21T13:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477417#M37374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried resetting the cursor yet?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;field0 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SKMS_tor'&lt;/SPAN&gt;
field1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SKMS'&lt;/SPAN&gt;
cursor0 &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;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc0&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field0&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
cursor1 &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;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row0 &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor0&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row1 &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor1&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; row0 &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; row1&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do do editing

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; skip editing

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;reset&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;/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;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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:05:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477417#M37374</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T21:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477418#M37375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would also suggest &lt;A _jive_internal="true" href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries"&gt;Turbo Charging Data Manipulation with Python Cursors and Dictionaries&lt;/A&gt;&amp;nbsp;(see Example 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using a search cursor, you would load a dictionary with values contained in the SKMS_for field along with the objectID or globalID for that dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then using an update cursor, if the field value is in the dictionary, you can do your editing or mark the row for later action.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2017 16:24:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477418#M37375</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2017-09-22T16:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477419#M37376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is what I needed. Thanks Joshua!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 19:13:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477419#M37376</guid>
      <dc:creator>TomaszChojnacki</dc:creator>
      <dc:date>2017-09-25T19:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477420#M37377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Randy,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Usefull stuff and I need to get into this. Lots of learning for me as a complete novice!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 19:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477420#M37377</guid>
      <dc:creator>TomaszChojnacki</dc:creator>
      <dc:date>2017-09-25T19:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477421#M37378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please mark a response as the answer to close the question out.&amp;nbsp; Also, if you haven't already, give a helpful to other responses that were, well, helpful. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Sep 2017 19:51:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477421#M37378</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-09-25T19:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477422#M37379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/bixb0012"&gt;bixb0012&lt;/A&gt;‌ ; thanks for providing the lesson in nested cursors.&amp;nbsp; That just went into my PythonSnipetss folder for future reference.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 13:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477422#M37379</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2017-09-26T13:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477423#M37380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was just focused on making the error go away.&amp;nbsp; As others pointed out in the comments, nesting cursors can lead to some big performance problems, and there may be other, better ways of accomplishing the work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 20:31:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477423#M37380</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-09-26T20:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477424#M37381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep-&amp;nbsp; just like it as an example; I need to figure out the whole dictionary thing.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2017 22:56:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477424#M37381</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2017-09-26T22:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: loop terminates</title>
      <link>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477425#M37382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For a bit of context, the reason this happens is because the data access (.da) cursors are implemented as &lt;A href="https://docs.python.org/2/library/stdtypes.html#iterator-types"&gt;iterators&lt;/A&gt;&amp;nbsp;which by design only allow one 'pass' and will then raise StopIteration exceptions on subsequent calls. If you want to repeatedly access the collection, or access items within the collection via an index, you can cast the iterator into a list. The .reset() method also works for multiple passes as Joshua has suggested but does not allow for indexing. The list approach is only viable if the data set you are working with is smaller than the amount of available RAM, so for larger data sets the iterator is necessary to feed the data 'piece by piece' into the script, so depending on the circumstances either approach has strengths and weaknesses.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Sep 2017 00:01:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loop-terminates/m-p/477425#M37382</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2017-09-27T00:01:31Z</dc:date>
    </item>
  </channel>
</rss>

