1

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])   
  • 1
    BERA's answer will solve your problem, but this double loop will be quite inefficient. It would probably work better with a dictionnary. – radouxju Nov 27 '18 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 dictionary – BERA Nov 27 '18 at 10:26
3

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

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.