I am creating code that accesses a shapefile named Schools.shp. I data I am trying to locate is the attribute field named FACILITIES. Within the FACILITIES field I am trying to get values that the field contains named HIGH SCHOOLS. In my code I need count the number of high schools I found. The value High School needs to be accessed through user input. (raw_input statement).
Using arcpy.da formatting.
import arcpy work = "c:\Scripts\Lab 6 Data" facility = "High School" whereClause = "\"FACILITY\" = 'HIGH SCHOOL' " shapefile = "Schools.shp" arcpy.env.workspace = work field = ['FACILITY'] searchCurs = arcpy.da.SearchCursor(shapefile, field, whereClause) row = searchCurs.next() for row in searchCurs: # using getValue() to get the name of the high school value = row.getValue("NAME") row = searchCurs.next() #count the number of specific facilities result = row.GetCount_management("NAME") count = int(result.getOutput(0)) print (count)
My issue is setting up the code so that the user can enter various facility types and the correct count for each facility is returned. Ex: User inputs High School, 29 is returned..... User inputs Junior High, 6 is returned.