1

I am working on a Python snippet try to use arcpy.da.SearchCursor() to extract value of certain field from a Info Table which generated by executing arcpy.Statistics_analysis().Here's my code:

arcpy.Statistics_analysis(fc,stats,[["Area","SUM"]],"")
Table = "D:/xxx/stats.info"
with arcpy.da.SearchCursor(Table,["AREA_SUM"]) as cursor:
    for row in cursor:
        Number = row[0]
print Number

However I always got RuntimeError: cannot open 'D:/xxx/stats.info'. I think it's caused by improper file name extention, but I'm not sure what the correct one is.

Plus: is there any other possible way of extracting value from Info Table using arcpy?

1

Isnt the dbase extension .dbf? Try placing the output from summary statistics in a file geodatabase, stats = r'C:\data.gdb\sumstat' then read this using the cursor.

But from what i can see there is no need for sumstat, you can do print sum([i[0] for i in arcpy.da.SearchCursor(fc,'Area')]) (see list comprehension)

Summary statistics is perhaps faster if your table is very big.

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.