<?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: For loop through UpdateCursor stops after first row in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/for-loop-through-updatecursor-stops-after-first/m-p/392976#M31112</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use forward slashes (/), double backslashes (\\), or raw strings (r"...") in your file paths.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 May 2012 18:13:08 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2012-05-28T18:13:08Z</dc:date>
    <item>
      <title>For loop through UpdateCursor stops after first row</title>
      <link>https://community.esri.com/t5/python-questions/for-loop-through-updatecursor-stops-after-first/m-p/392974#M31110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am running this script here to try and match some various fields within the same file. So I have setup a search and an update cursor within that file. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I run the script, the main part of the script where the update cursor for loop exists, stops after the first entry. Clearly I am doing something wrong. Is this just a problem with trying to run two cursors in the same file? I figured it would not be a problem since the search cursor should not try and get any kind of lock on the data. Any help would be much appreciated. Code is below. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
#municLayer = arcpy.mapping.(mxd, "MUNICPIOS")
municLayer = arcpy.UpdateCursor("C:\File")
municSearch = arcpy.SearchCursor("C:\File")

def matchMunic(municipalityname):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in municSearch:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; munictomatch = strip_accents(row.NOM_MUN.upper())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enttomatch = strip_accents(row.NOM_ENT.upper()[:3])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stringtomatch = munictomatch+" ("+enttomatch+")"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print stringtomatch+" =? "+municipalityname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if municipalityname == stringtomatch:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "We have found a match for " + stringtomatch
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; municSearch.reset()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return row.Count
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; municSearch.reset()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 303
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
def strip_accents(string):
&amp;nbsp;&amp;nbsp;&amp;nbsp; import unicodedata
&amp;nbsp;&amp;nbsp;&amp;nbsp; return unicodedata.normalize('NFKD', unicode(string)).encode('ASCII', 'ignore')&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

for row in municLayer:
&amp;nbsp;&amp;nbsp;&amp;nbsp; municname = row.Munic
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.MunicPytho = matchMunic(municname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; municLayer.updateRow(row)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2012 23:48:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/for-loop-through-updatecursor-stops-after-first/m-p/392974#M31110</guid>
      <dc:creator>JaredMorante</dc:creator>
      <dc:date>2012-05-25T23:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: For loop through UpdateCursor stops after first row</title>
      <link>https://community.esri.com/t5/python-questions/for-loop-through-updatecursor-stops-after-first/m-p/392975#M31111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure I follow what you are doing exactly. I wouldn't use multiple cursors on the same dataset, I can't imagine that would ever work. I would use your search cursor to build a dictionary or list of the values you want to compute with your update cursor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 May 2012 15:12:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/for-loop-through-updatecursor-stops-after-first/m-p/392975#M31111</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-05-28T15:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: For loop through UpdateCursor stops after first row</title>
      <link>https://community.esri.com/t5/python-questions/for-loop-through-updatecursor-stops-after-first/m-p/392976#M31112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use forward slashes (/), double backslashes (\\), or raw strings (r"...") in your file paths.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 May 2012 18:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/for-loop-through-updatecursor-stops-after-first/m-p/392976#M31112</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-05-28T18:13:08Z</dc:date>
    </item>
  </channel>
</rss>

