I am trying to use an update cursor ina for loop and I keep getting an IOError that I don't understand.The script is looping through my table, selecting records one by one, then doing a select by location to fins out how many buffers intersect the selected record. The number of buffers that intersect that record need to be recorded in the attribute table. A sub-set of my code and error statements are below.RCWfieldList = ["three_mi","avg_gs","PGB_avg","one_25mi","pot_hab"] ParcelFieldList=arcpy.ListFields(parcelsFC) for RCWfield in RCWfieldList: if RCWfield in ParcelFieldList: print "Field", RCWfield, "found in", parcelsFC arcpy.AddMessage("Field " + RCWfield + " found in " + parcelsFC) else: # else the fieldname is not yet a field in the table, field will be added print"Field", RCWfield, "NOT found in", parcelsFC arcpy.AddMessage("\nField " + RCWfield + " NOT found in " + parcelsFC) arcpy.AddField_management(parcelsFC, RCWfield, "DOUBLE") print RCWfield, "created" arcpy.AddMessage(RCWfield+" created/n") #Select out each parcel record one by one and evalauate how many cluster buffers intersect with that parcel. #Update Parcel Attribute Table field three_mi with the # of buffers that intersect that parcel for parcel in range(0,1092): FID = "FID=%s" % (parcel) arcpy.SelectLayerByAttribute_management(parcelsFL,"NEW_SELECTION",FID) arcpy.SelectLayerByLocation_management(CbuffersFL,"INTERSECT",parcelsFL) bufferCount = int(arcpy.GetCount_management(CbuffersFL).getOutput(0)) uc=arcpy.UpdateCursor(parcel) for line in uc: line.three_mi = bufferCount uc.updateRow(line) #Actually changes the table values to buffer count del line del uc #print "There are", bufferCount, "buffers that intersect with parcel FID #", FID arcpy.SelectLayerByAttribute_management(parcelsFL,"CLEAR_SELECTION")
Error Statement:Traceback (most recent call last): File "P:\Environmental Division\The Nature Conservancy\TNC GIS Data\TNC GIS Projects\RCW\Code\ForLoop.py", line 68, in <module> uc=arcpy.UpdateCursor(parcel) File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 841, in UpdateCursor return gp.updateCursor(*args) File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 362, in updateCursor self._gp.UpdateCursor(*gp_fixargs(args))) IOError: "0" does not exist
I'm not understanding why its saying IOError "0" does not exist. It's doing this on the very first record. The input value for this record should be 3. All fields that need to be populated currently have a value of 0. Field properties = double. Thanks in advance