Below mentioned one is a part of my script.This is working when I assinged numbers for f.(Instead of "f" I have substitute 2.Then it is working).But i want to run this based on the no of rows of the table named "TL"(f).Can any one suggest a method to do this?
f=arcpy.GetCount_management(TL)
with arcpy.da.UpdateCursor(PCL_Info, ['PCL_PG_ID','PCL_IF_LN','PCL_IF_CN','PCL_IF_RM','PCL_IF_LU','PCL_IF_EL','globalid','created_user','created_date','last_edited_user','last_edited_date','adm_gn_ix']) as cursor:
for row in cursor:
for x in range(0,f):
if(row[0] == parcel_ID[x]):
c.append(row[0])
c.append(row[1])
c.append(row[2])
asked Nov 27, 2018 at 9:59
-
1BERA's answer will solve your problem, but this double loop will be quite inefficient. It would probably work better with a dictionnary.radouxju– radouxju2018年11月27日 10:14:15 +00:00Commented Nov 27, 2018 at 10:14
-
Hard to tell since we dont know what parcel_ID or c is, or the size of TL. parcel_ID could be a dictionaryBera– Bera2018年11月27日 10:26:53 +00:00Commented Nov 27, 2018 at 10:26
1 Answer 1
Change:
f=arcpy.GetCount_management(TL)
To:
f=int(arcpy.GetCount_management(TL).getOutput(0))
Without getOutput, f is a Result object, not the actual count.
Example:
import arcpy
fc = r"C:\Test\Buildings.shp"
arcpy.GetCount_management(fc)
<Result '9'>
arcpy.GetCount_management(fc).getOutput(0)
'9'
int(arcpy.GetCount_management(fc).getOutput(0))
9
answered Nov 27, 2018 at 10:05
lang-py