Here is my script:
import arcpy
# set environment, workspace, and output location
arcpy.env.overwriteOutput = 1
arcpy.env.workspace = r"Database Connections\Transportation.sde"
output_loc = r"C:\Users\johndiaz\Documents\Outerspatial_Shapefiles"
agency_list = ['CASP', 'CIC', 'MRCA/SMMC', 'LACODPR', 'NPS', 'PCTA']
# assign variables to layers
th_fc = r"Database Connections\Transportation.sde\eGIS_Transportation.EGIS.DPR_TRAILHEADS"
poi_fc = r"Database Connections\Transportation.sde\eGIS_Transportation.EGIS.DPR_TRAILS_POI"
trails_fc = r"Database Connections\Transportation.sde\eGIS_Transportation.EGIS.DPR_TRAILS"
# shapefiles for trailheads and poi
for list in agency_list:
print "generating trailhead and poi shapefiles"
where_clause = "agency = '" + list + "'"
arcpy.MakeFeatureLayer_management (th_fc, "th_lyr")
arcpy.SelectLayerByAttribute_management ("th_lyr", "NEW_SELECTION", where_clause)
output_th = "\\" + list + "_TRAILHEADS.shp"
arcpy.FeatureClassToFeatureClass_conversion ("th_lyr", output_loc, output_th)
arcpy.MakeFeatureLayer_management (poi_fc, "poi_lyr")
arcpy.SelectLayerByAttribute_management ("poi_lyr", "NEW_SELECTION", where_clause)
output_poi = "\\" + list + "_POI.shp"
arcpy.FeatureClassToFeatureClass_conversion ("poi_lyr", output_loc, output_poi)
print "trailhead and poi shapefiles complete"
for list2 in agency_list:
print "generating trails shapefiles"
where_clause = "trail_type = 'Existing' AND agency = '" + list2 + "'"
arcpy.MakeFeatureLayer_management (trails_fc, "trails_lyr")
arcpy.SelectLayerByAttribute_management ("trails_lyr", "NEW_SELECTION", where_clause)
output_trails = "\\" + list + "_TRAILS.shp"
arcpy.FeatureClassToFeatureClass_conversion ("trails_lyr", output_loc, output_trails)
print "trails shapefiles complete"
print "SCRIPT COMPLETE"
If i remove the list item 'MRCA/SMMC' the script runs fine. Otherwise, I get this error:
Message File Name Line Position
Traceback
<module> C:\Users\johndiaz\Documents\trails_app_create_shapefiles.py 36
FeatureClassToFeatureClass c:\program files (x86)\arcgis\desktop10.5\ArcPy\arcpy\conversion.py 1891
ExecuteError: ERROR 000210: Cannot create output C:\Users\johndiaz\Documents\Outerspatial_Shapefiles\\MRCA/SMMC_TRAILHEADS.shp
Failed to execute (FeatureClassToFeatureClass).
Any advice?