Python Error With UpdateCursor

586
3
03-16-2012 04:28 PM
ShaunWeston
Occasional Contributor
I keep getting this error message when I try run a script to update some fields:

RuntimeError: ERROR 999999: Error executing function.
Workspace or data source is read only.
Workspace or data source is read only. [The C:\Data\Current Projects\Goldpine\Scratch.gdb workspace is read only.]

This seems to only come up when I run it on larger datasets?

This is my code:

import arcpy


# Overwrite existing data
arcpy.env.overwriteOutput = True


import arcpy


# "C:\\Data\\Current Projects\\Goldpine\\Scratch.gdb\\ParcelsWithAddressPropertiesSELECTION"
# arcpy.GetParameterAsText(0)
myFile = "C:\\Data\\Current Projects\\Goldpine\\Scratch.gdb\\ParcelsWithAddressProperties"
sortField = "PAR_ID"
appendField = "Full_Address"
multiField = "MultipleAddresses"
parcelID = "PAR_ID"


rows = arcpy.UpdateCursor(myFile,"","","",sortField + " A")


for row in rows:
   if (row.FREQUENCY == 1):  
      appendValue = row.getValue(appendField)
      row.setValue(multiField, appendValue)
      rows.updateRow(row)
   if (row.FREQUENCY > 1):
      x = 0
      addressList = ""
      while (x < row.FREQUENCY):
        if  (x == 0):
          previousParcel = row.getValue(parcelID)       
          appendValue = row.getValue(appendField)       
          addressList = appendValue
          row.setValue("MultipleAddresses", addressList)
          rows.updateRow(row)
          x += 1            
        else:   
          currentParcel = row.getValue(parcelID)    
          if (currentParcel == previousParcel):
             appendValue = row.getValue(appendField)
             if (len(addressList) > 200):
                addressList = addressList
             else:   
                addressList = addressList + " || " + appendValue
             row.setValue("MultipleAddresses", addressList)
             rows.updateRow(row)
             x += 1
      
Tags (2)
0 Kudos
3 Replies
ChrisSnyder
Regular Contributor III
Are you sure the FGDB isn't compressed (aka in a read only state)?

How large is a "larger dataset"?
0 Kudos
WilliamIde
New Contributor II
I have also got the dredded 999999.  For me it was because I had the FC that I was running the python script against open in arcmap.  Some sort of lock problem.  Try closing Arcmap and running your script.  Maybe even wait a few seconds after it closes.  It seems that the lock is not updated as fast as we would like.
0 Kudos
JeffReinhart1
New Contributor
Looks like Shaun and I are trying to do the same thing, which is to assign a unique id to a field (mine is "LNDOWNR_ID") for any addresses that are the same in another field (mine is "TEMP1"), with the id being generated from a counter that gets updated if the next address is different than the last.

My guess is this is a memory issue�?� on the first run my process gets through 8002 records then quits (I queried the field that is being updated on "LNDOWNR_ID" IS NOT NULL in ArcMap after running it). I have tried running the script with only ArcCatalog running, and it still only gets through 8002 records out of 71000. I am running on a Windows XP machine with 3.48gb RAM. If anyone can shed further light on this, that would be appreciated.

My guess is Shaun has found a work-around by now, but here is mine: I am running the script in batches with a where clause in the update cursor:
UpdateCursor(inputFC, '\"LNDOWNR_ID\" IS NULL;', "", "", "TEMP1 A"
and bumping up the count for each run. Its tedious, I may as well have done the calculation in Excel.
0 Kudos