1

I am trying to get a where_clause working on a UpdateCursor (arcpy.da). I can get it to work fine with a SearchCursor, but for some reason the same clause throws a RuntimeError: General function failure error.

import arcpy
from arcpy import env
env.workspace = "C:/mydata/mylocation/Results"
fc = "airports.shp"
delimfield = arcpy.AddFieldDelimiters(fc, "STATE")
queryString = delimfield + " <> 'AK'"
cursor = arcpy.da.UpdateCursor(fc,["STATE"], queryString)
for row in cursor:
    print row
    row[0]="AK"
    cursor.updateRow(row)    
del row
del cursor
  • 1
    Try making your workspace defined to the results directory and the fc just the airports.shp. – artwork21 Jun 21 '15 at 2:36
  • That didn't seem to do the trick. But, I did discover if I move my airports into a geodatabase it seems to work. I wonder if this is a bug of some kind... – geo derek Jun 21 '15 at 13:26
  • have you already solved it? – Abc1 Nov 29 '17 at 20:16
1

You may have the feature class or raster currently open in ArcMap.

I had this issue (same ambiguous error as I began the for loop) when trying to update a GRID VAT, and it worked after I closed my ArcMap session.

0

Here are few things to be mindful of when using update cursor and env workspace related to your question:

  1. Setup up workspace to data parent directory (e.g. either to results dir or .gdb)
  2. If using env workspace to define fc variable as either 1. for shp, fc = 'airport.shp' or 2. as .gdb fc reference, fc = 'airports'
  3. Use same field names between the query variable and cursor reference (here you are using two different fields STATE and NAME)
  • I updated my script, but still am getting this error: RuntimeError: General function failure error – geo derek Jun 23 '15 at 20:24
  • Are you receiving a line number where it is failing at? – artwork21 Jun 24 '15 at 2:15
  • Hi. Yes it is the line that starts the for loop: for row in cursor: – geo derek Jun 25 '15 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.