AnsweredAssumed Answered

RuntimeError using searchCursor

Question asked by JuttaSchiller on Oct 2, 2014
Latest reply on Oct 2, 2014 by JuttaSchiller

I always get the following error. I really don’t know what to do. Also tried to work with a fgdb and got the same error. Do you have an idea what I’m doing wrong? This is just a part of the code...



import arcpy
import os
from arcpy import env

env.overwriteOutput = True
env.workspace = r"D:\Users\julia\erste_aufg\cities_UA"
env.qualifiedFieldNames = False

fcResult = arcpy.ListFeatureClasses("*_result.shp")
for shpresult in fcResult:
    shpresultName = os.path.splitext (shpresult) [0]
    print shpresultName 
    outputfile = env.workspace + "\\" + shpresultName + "_.txt"
    f = open (outputfile, 'w')
    f.write ("ID,Combi1,Combi2,Combi3\n")
    f.close ()
    f = open (outputfile, 'a')

    valueDict = {}    
    with arcpy.da.SearchCursor(env.workspace + "\\" + shpresultName, ["Id", "GRIDCODE"]) as searchRows:
        for searchRow in searchRows:
                keyValue = searchRow[0]
                gridcode = searchRow[1]
                if not keyValue in valueDict:
                        valueDict[keyValue] = [gridcode]
                elif not gridcode in valueDict[keyValue]: