Where clause using result of expression

Discussion created by smfranklin on Nov 1, 2011
Latest reply on Nov 8, 2011 by jskinner-esristaff
I am trying to write a python program using a "counties.shp" shapefile and a "hospitals.shape" shapefile. I need to find out which counties have more than one million population in 2000 and for the counties with more than one million people in 2000, find out how many hospitals are within each county.

Counties.shp has a field called POP2000 that lists the county's population
Hospitals.shp has a field called COUNTY that lists the county the hospital is found in.

I was able to do the first part by:

def findpop():
    rows = arcpy.SearchCursor("counties.shp")
    row =
    popFld = "POP2000"
    while row:
        ctyPop = row.getValue(popFld)
        if ctyPop > 999999 :
            ctyName = row.NAME
            #print "County: ", ctyName, "\tPopulation: ", ctyPop
        row =

but I am having trouble with the WHERE clause on the second part. I need to use the identified counties from the first operation for the next one. This is what I've come up with, but after making quite a mess of it, I'm of ideas.. can someone help?

SO say, County1 and County2 had more than 1 million people
I need to find out how many hospitals are in County 1
and how many are in County 2

ctyFld = "COUNTY"
where = ctyFld = ctylst[i]
rows = arcpy.SearchCursor("hospital.shp, where")
row =

hospTotal = 0
i = 0
while row :
    ctychck = ctylist[i]
    where "
    hospTotal += 1
    row =
print hospTotal