I am desperately trying to export the values in a raster table to a .txt file. I've seen some other folk post about this, but for some reason can't get the code to work in my case.
I have a raster, with table already built, called "shed". I simply want to export two fields, "Value" and "Count", to a .txt or .csv file (called "try" in this case). So far, I haven't even been able to get a script that even looks at the raster's table. So far I have:
outfile=open("E:/Weathering_GIS/try.txt",'w')
rows=arcpy.SearchCursor('shed',"","","Value;Count","")
for row in rows:
val=row.getValue('Value')
count=row.getValue('Count')
outfile.write(val)
But "val" and "count" always fail to become anything- they just remain empty values! Am I missing something? Maybe some sort of import I have overlooked?


arcpy? You can just try a simple export from the attribute table if you urgently need the data. Thirdly, are you reading in the raster properly? You can't read in the file using the name unless you set the working directly properly using something likeenv.workspace = r"D:\DATA\\", after the linefrom arcpy import env– djq Feb 14 '12 at 2:15