Reading values from file Geodatabase table and assigning those values to variable

arcgis-proarcpyfile-geodatabasezonal statistics

I created a table using the zonal statistics as a table tool which contains some percentile values of a raster (90%, 75%, etc). The table is 1 row and contains the percentile values. I want to take each percentile value and assign it to a variable (PER_90, PER_75, …).

How do you use ArcPy to read in the table and assign values to these variables?

Best Answer

Use da.SearchCursor():

import arcpy

zonetable = r'C:\folder\data.gdb\zonstats' #Change
fieldnames = ['field90', 'field75','field50'] #Change

PER_90, PER_75, PER_50 = [row for row in arcpy.da.SearchCursor(zonetable, fieldnames)][0]
Related Question