AnsweredAssumed Answered

Script crashes

Question asked by BLomas on Mar 24, 2016
Latest reply on Mar 25, 2016 by wwmiller68

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.

 

 

from time import strftime 
    
print "Start script: " + strftime("%Y-%m-%d %H:%M:%S") 
    
import arcpy
from arcpy import env  
     
sourceFC = r'M:\ParcelDatabase\...\Feb_2016_Ownership'
     
sourceFieldsList = ["PARCEL","SITUS", "CURRENT_OWNER", "CO_OWNER", "OWNER_MAILADDR", "OWNER_CITY_STATE", "OWNER_ZIPCODE", "TAX_DISTRICT", "TAX_CODE", "SEC", "TOWNSHIP", "RANGE", "LEGAL"]  
     
# Use list comprehension to build a dictionary from a da SearchCursor  
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}  

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']  

edit = arcpy.da.Editor(r"Database Connections\parcelpubdelete.sde")
edit.startEditing(False, True)
edit.startOperation()    
print "entered edit session"

with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:  
     for updateRow in updateRows:  
         # store the Join value of the row being updated in a keyValue variable  
         keyValue = updateRow[0]  
         # verify that the keyValue is in the Dictionary  
         if keyValue in valueDict:  
             # transfer the values stored under the keyValue from the dictionary to the updated fields.  
             for n in range (1,len(sourceFieldsList)):  
                 updateRow[n] = valueDict[keyValue][n-1]  
             updateRows.updateRow(updateRow)  
     
del valueDict

edit.stopOperation()
edit.stopEditing(True) 
     
print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S") 

Outcomes