<?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: Script crashes in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230685#M17870</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may also want to consider the number of records your dealing with. I would try creating a copy (for backup) and let it run for a while.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Mar 2016 20:27:51 GMT</pubDate>
    <dc:creator>WesMiller</dc:creator>
    <dc:date>2016-03-24T20:27:51Z</dc:date>
    <item>
      <title>Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230682#M17867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I run the following script it just spins and spins then arcmap turns to "not responding". I'm trying to update a versioned parcel layer using a .mdb file. When I "quote" out the updatecursor everything seems to run fine and it seems to enter the edit session as well. Any ideas on what it could be? I'm stuck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from time import strftime 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "Start script: " + strftime("%Y-%m-%d %H:%M:%S") 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
import arcpy
from arcpy import env&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
sourceFC = r'M:\ParcelDatabase\...\Feb_2016_Ownership'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
sourceFieldsList = ["PARCEL","SITUS", "CURRENT_OWNER", "CO_OWNER", "OWNER_MAILADDR", "OWNER_CITY_STATE", "OWNER_ZIPCODE", "TAX_DISTRICT", "TAX_CODE", "SEC", "TOWNSHIP", "RANGE", "LEGAL"]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Use list comprehension to build a dictionary from a da SearchCursor&amp;nbsp; 
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}&amp;nbsp; 

arcpy.env.workspace = r"Database Connections\parcelpubdelete.sde" 

updateFC = r"Database Connections\...\ArcGISSDE.SDE.TaxParcel"

updateFieldsList = ['PARCELID','SITEADDRESS','OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'ZIPCODE', 'TAX_DIST', 'TAX_CODE', 'SEC', 'TWN', 'RGE', 'PRPRTYDSCRP']&amp;nbsp; 

edit = arcpy.da.Editor(r"Database Connections\parcelpubdelete.sde")
edit.startEditing(False, True)
edit.startOperation()&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "entered edit session"

with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for updateRow in updateRows:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # store the Join value of the row being updated in a keyValue variable&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; keyValue = updateRow[0]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # verify that the keyValue is in the Dictionary&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if keyValue in valueDict:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # transfer the values stored under the keyValue from the dictionary to the updated fields.&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for n in range (1,len(sourceFieldsList)):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow&lt;N&gt; = valueDict[keyValue][n-1]&amp;nbsp; &lt;/N&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; updateRows.updateRow(updateRow)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
del valueDict

edit.stopOperation()
edit.stopEditing(True) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S") &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:12:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230682#M17867</guid>
      <dc:creator>BrianLomas</dc:creator>
      <dc:date>2021-12-11T11:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230683#M17868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without an explicit error message, it is difficult to offer suggestions.&amp;nbsp; I would add some additional print statements to see what part of the code in the update cursor is getting hung up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 20:11:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230683#M17868</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-03-24T20:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230684#M17869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may be extra picky but it looks like there are five spaces for the indent in line 27 (where it should be four). I would hope python code could get around that, but I don't know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not that then, do you need to start an edit session for UpdateCursor? I was not aware that you needed to (but I do not have a ton of experience using UpdateCursor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(oh, just answered my question about the Edit session and cursors looking at this thread: &lt;A href="https://community.esri.com/thread/173905"&gt;can't edit row with arcpy.da.updatecursor in arcmap&lt;/A&gt;) &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 20:15:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230684#M17869</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-03-24T20:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230685#M17870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may also want to consider the number of records your dealing with. I would try creating a copy (for backup) and let it run for a while.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 20:27:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230685#M17870</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-03-24T20:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230686#M17871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Double-check and go over the field lists you have and verify there's no discrepancies between them and the actual sources.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, are you using a Joined field to populate some other source?&amp;nbsp; If so, make sure you fully qualify the field's joined name, not just it's alias or original source name. (just a guess here).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 20:29:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230686#M17871</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-03-24T20:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230687#M17872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure if this is the problem, but you probably shouldn't be using the name of the command "updateRow" for the name of a variable.&amp;nbsp; For example, instead of&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for updateRow in updateRows:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;put&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for r in updateRows:&amp;nbsp; &lt;/EM&gt;​&lt;/P&gt;&lt;P&gt;Just wondering, because everything else looks okay at first glance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 20:39:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230687#M17872</guid>
      <dc:creator>RuthBowers</dc:creator>
      <dc:date>2016-03-24T20:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230688#M17873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I placed a few print statements and everything seemed to be running. So, I added a counter and the script is in fact running but it's only cycling through a record every second or so. We have over 10,000 rows that will have 12 different attributes changed, at this rate it will take entirely too long. When I run the script on a fdb or shp is runs in 2 seconds with the same number of records. I'm new to scripting so I'm not sure if there's something I'm doing wrong. Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 13:13:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230688#M17873</guid>
      <dc:creator>BrianLomas</dc:creator>
      <dc:date>2016-03-25T13:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230689#M17874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I kept getting an error saying I couldn't edit the layer outside an edit session even if I was in an edit session in Arcmap. So, I added the edit operation to the code and it stopped tripping the error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 13:17:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230689#M17874</guid>
      <dc:creator>BrianLomas</dc:creator>
      <dc:date>2016-03-25T13:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230690#M17875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I double checked the specified fields and everything seems to be good to go... The plan is to join a mdb and a versioned fc then update the fc with the attributes of the mdb.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 13:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230690#M17875</guid>
      <dc:creator>BrianLomas</dc:creator>
      <dc:date>2016-03-25T13:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230691#M17876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the time to update a record linear, i.e., does it stay constant over time or get progressively slower?&amp;nbsp; There have been discussions on GeoNet about the degraded performance of update cursors over time on large record sets.&amp;nbsp; That said, the performance usually starts out reasonable and gets worse over time.&amp;nbsp; Also, 10,000 records isn't that large, but it is starting to enter the range where some people say they have issues.&amp;nbsp; Also, are you using a Parcel Fabric?&amp;nbsp; I have also heard of slow update performance with parcel fabric over regular feature classes in enterprise geodatabases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Overall, I think you should open an incident with Esri Support.&amp;nbsp; If it is taking 1 sec/record from the start, something else is going on either in the application or backend database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 13:26:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230691#M17876</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-03-25T13:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230692#M17877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the info Joshua. I started it again this morning and it ran about 1,000/min til about 5,000 then slowed up a bit, at ~7000 it just stopped. There's no message and I can't click on anything, it just froze... We're not using parcel fabric. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 14:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230692#M17877</guid>
      <dc:creator>BrianLomas</dc:creator>
      <dc:date>2016-03-25T14:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230693#M17878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK.&amp;nbsp; Seeing a parcel fabric is not involved, and the performance does degrade over time, this seems to generally fit into other discussions/complaints on GeoNet about update cursors on medium to large datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A couple of ideas come to mind.&amp;nbsp; First, can you go with &lt;SPAN&gt;multiuser_mode&lt;/SPAN&gt; as False?&amp;nbsp; If so, does that make a difference.&amp;nbsp; Second, even though you have &lt;SPAN&gt;with_undo&lt;/SPAN&gt; as False, you are still trying to update ~10,000 in one operation.&amp;nbsp; You could use one edit session but chunk it up into multiple edit operations.&amp;nbsp; In effect, iterate over the records committing the updates after every 1000-2000 records.&amp;nbsp; Unfortunately with such an approach, the update cursor needs to be instantiated and released with each edit operation, so there is some work to ensure the records are ordered properly and divided up so records aren't missed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 15:38:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230693#M17878</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-03-25T15:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script crashes</title>
      <link>https://community.esri.com/t5/python-questions/script-crashes/m-p/230694#M17879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if this will work with version data, but you may be better off doing a join and select those records that have changed. &lt;/P&gt;&lt;P&gt;Workflow:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Add Join &lt;/LI&gt;&lt;LI&gt;for field in fields (on target)&lt;/LI&gt;&lt;LI&gt;select &amp;lt;&amp;gt; to see if attributes don't match&lt;/LI&gt;&lt;LI&gt;calculate field &lt;/LI&gt;&lt;LI&gt;next field repeat steps 3,4&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2016 15:59:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-crashes/m-p/230694#M17879</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-03-25T15:59:48Z</dc:date>
    </item>
  </channel>
</rss>

