I have a list of shapefiles that I need to select within a loop, to see if the file is there or not.
I tried several loops if, elif ... Just get an error???
I would appreciate any suggestions, to get this working.
#check file exists here?
fcList = arcpy.ListFeatureClasses()
for shapefile in fcList:
if shapefile == "Bus Stops":
print "1" ++ shapefile
elif shapefile == "Cluster_Sites":
print "2" ++ "shapefile"
elif shapefile == "Highway Boundary":
print "3" ++ "shapefile"
elif shapefile == "Street Lighting":
print "4" ++ "shapefile"
elif shapefile == "Road_Traffic_Collisions":
print "5" ++ "shapefile"
else:
print "end"
The code prints:
end
end
end
<type file>
There are 3 shapefiles in the directory.
There could be 0 to10 shapefiles
Solved! Go to Solution.
Hi Darren,
Thanks, when I added the .shp the script worked.
Got back
Cluster_sites.shp
Fixed and Mobile Camera.shp
Road_Traffic_Collisions.shp
<type 'file'>