I'm working on a script that prints the names of hospitals that are within a certain zip-code. When I run my code, though, python keeps giving me an Error message that says that my Hospitals shapefile does not exist. I've tested to see whether or not the shapefile exists using arcpy.Exists and I get the answer "True". I was also wondering if it might be because the file is locked in some way but I've tried deleting my objects and cursors as well as closing arcgis and restarting python and nothing has changed.
Can anyone tell me why Python is not recognizing my shape file? Thank you!
Code for reference:
import arcpy #set workspace work=raw_input("work= ") arcpy.env.workspace=work zip5=input("zip5= ") strZip= str(zip5) arcpy.env.overwriteOutput = True def searchHospitals(work,zip5): fc= "Hospitals.shp" #create a list to store values hospitals=[] whereClause= '"ZIPCODE" LIKE'+"'%s%%'"% strZip sCursor= arcpy.SearchCursor(fc, whereClause, "", "", "") for row in sCursor: rowHospital = row.getValue("NAME") #if rowHospital value is not already in hospitals, append. if (not(rowHospital in hospitals)): hospitals.append(rowHospital) #number of hospitals in list count= len(hospitals) #print results print hospitals print "Total %s hospitals were found in zip-code %s"%(count, zip5) del row, sCursor
أكثر...
Can anyone tell me why Python is not recognizing my shape file? Thank you!
Code for reference:
import arcpy #set workspace work=raw_input("work= ") arcpy.env.workspace=work zip5=input("zip5= ") strZip= str(zip5) arcpy.env.overwriteOutput = True def searchHospitals(work,zip5): fc= "Hospitals.shp" #create a list to store values hospitals=[] whereClause= '"ZIPCODE" LIKE'+"'%s%%'"% strZip sCursor= arcpy.SearchCursor(fc, whereClause, "", "", "") for row in sCursor: rowHospital = row.getValue("NAME") #if rowHospital value is not already in hospitals, append. if (not(rowHospital in hospitals)): hospitals.append(rowHospital) #number of hospitals in list count= len(hospitals) #print results print hospitals print "Total %s hospitals were found in zip-code %s"%(count, zip5) del row, sCursor
أكثر...