AnsweredAssumed Answered

Get Specific Field 'value' and return names and count.

Question asked by Aleah2vw on Jan 31, 2017
Latest reply on Jan 31, 2017 by bixb0012

I have this attribute table where I am supposed to access the Field "Facility" and based on what type of facility the user enters, my code is supposed to return the names and count of that facility type. For example: I enter High School as my facility type. My code needs to return the names of the high schools, as well as how many high schools there are. Oh and this is supposed to operate as a function.


    import arcpy

    arcpy.env.workspace = raw_input("Enter the workspace path: ")# c:\Scripts\Lab 6 Data
    shapefile = "Schools.shp"
    work = arcpy.env.workspace
    sTyp = "HIGH SCHOOL"

    def numSchools(work, shapefile, sTyp):
         sc = arcpy.SearchCursor(work, shapefile)
         field = "FACILITY"
         for row in sc:
             if row.getValue(field)== sTyp
             return row.getValue("NAME")

    numSchools(work, shapefile, sTyp)