Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Looping Through FeatureClasses

$
0
0
I am trying to build a script that will iterate through each feature class while capturing the last record per the required query. I haven't had a chance to really test this out yet. Just seems like I might be able to streamline the code a bit...any feedback is welcome.

Code:

# List People and Feature Classes
people = ['TOM','ADAM','BRIAN','STEVE']
lstfc = arcpy.ListFeatureclasses(workspace)
for fc in lstfc:
                #Loop through each feature class printing the last record date that was updated by each person
                lstTOM = [row.getvalue('updated_date') for row in arcpy.SearchCursor(fc,"PERSON='TOM')
                print str(people[0]) + "has" + " last" + "updated" + "on" + str(lstTOM[-1])
                lstADAM = [row.getvalue('updated_date') for row in arcpy.SearchCursor(fc,"PERSON='ADAM')
                print str(people[1]) + "has" + " last" + "updated" + "on" + str(lstADAM[-1])
                lstBRIAN = [row.getvalue('updated_date') for row in arcpy.SearchCursor(fc,"PERSON='BRIAN')
                print str(people[2]) + "has" + " last" + "updated" + "on" + str(lstBRIAN[-1])
                lstSTEVE = [row.getvalue('updated_date') for row in arcpy.SearchCursor(fc,"PERSON='STEVE')
                print str(people[3]) + "has" + " last" + "updated" + "on" + str(lstSTEVE[-1])


Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images