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]:
valueDict[keyValue].append(gridcode)
Solved! Go to Solution.
Find my mistake: I just had to enter shpresult instead of env.workspace + "\\" + shpresultName in the cursor.
Sorry, for the question.
Find my mistake: I just had to enter shpresult instead of env.workspace + "\\" + shpresultName in the cursor.
Sorry, for the question.
Wird denn die txt in dem Ordner erstellt?
ja, dass wird sie.
Ja wunderbar - gelöst - selbst ist die Frau
Yes!