AnsweredAssumed Answered

How do I add a list to arcpy.da.SearchCursor?

Question asked by NEOMAPPER on May 18, 2018
Latest reply on May 18, 2018 by NEOMAPPER

How can I use systemList variable with several defined types with arcpy.da.SearchCursor? Currently, I have it looking at '009' but I would like it to find every system defined in systemList.

 

import arcpy

fc = 'Database Connections\SDE.sde\NEO_1.SDE.P_PipeSystem\NEO_1.SDE.P_Meters'
field = 'SYSTEMNUMBER'

systemList = ["009", "10", "12", "13", "21", "22", "27", "27A", "27B", "27C", "30", "31", "33", "34", "35", "36"]


cursor = arcpy.da.SearchCursor(fc, (field, "SYSTEMNUMBER"), """SYSTEMNUMBER = '009'""")
count = 0

# For each row print the
for row in cursor:
    # Print the name of the gas systems
    #
    #print(row[1])
    #result = arcpy.GetCount_management(fc)
    #print('{} has {} records'.format(row[1], result[0]))
    count += 1 

print('{} has {} records'.format(row[1],count)) 

Outcomes