Based on the code below how can I store the resultant value from GetCount in a numeric datatype? When I try the `int` function I get the following error:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'Result'
Code:
import arcpy
arcpy.env.workspace = "C:/data/data.gdb"
Count = arcpy.management.GetCount("roads")
Count = int(Count)
Solved! Go to Solution.
Never mind, the following fixes it by adding getOutput(0)
import arcpy
arcpy.env.workspace = "C:/data/data.gdb"
Count = int(arcpy.management.GetCount("roads").getOutput(0))
This post helped:
Never mind, the following fixes it by adding getOutput(0)
import arcpy
arcpy.env.workspace = "C:/data/data.gdb"
Count = int(arcpy.management.GetCount("roads").getOutput(0))
This post helped:
Always proving there's more than one way to skin a cat[fish]:
count = int(arcpy.management.GetCount('feature')[0])
If you ask for the first index on that Result object, you get the actual result/number, itself—albeit as a string (I think). Don't quote me on the exact datatype, but I know this is the syntax I typically use, and I haven't seen any errors from it, yet.