AnsweredAssumed Answered

Parse Invalid Characters Arcpy

Question asked by Russel204 on Jun 24, 2015
Latest reply on Jun 29, 2015 by granth

Hi all,


I'm back at it again. I've written a script to Iterate through an MXD and export all features within 50 miles of my state to a feature class. There are over 550 FCs to process and it keeps failing due to invalid characters. Does arcpy offer a way to parse out invalid characters when naming a conversion output?


Below is the code i'm referencing


import arcpy
import glob
import os
files = glob.glob(r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015\*')
for f in files:

mxd = arcpy.mapping.MapDocument(r'C:\Users\JOC-001\Documents\GIS\HSIP\Infrastructure\HSIP_Gold_2015_Infrastructure.mxd')  
layers = arcpy.mapping.ListLayers(mxd)  
for lyr in layers:  
    if lyr.isGroupLayer:
        print lyr
        arcpy.SelectLayerByLocation_management(lyr, "WITHIN_A_DISTANCE", r"C:\Users\JOC-001\Documents\ArcGIS\Default.gdb\Illinois", "50 Miles", "NEW_SELECTION")  
        arcpy.FeatureClassToFeatureClass_conversion(lyr, r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015', str(