How to simplify this code and do some improvement to get each feature class record from the shapefile?
import arcpy
featureClass = r"C:\Users\TL\Desktop\812test\SplitAllRoutes_FacID\FacID1655.shp"
count = int(arcpy.GetCount_management(featureClass).getOutput(0))
# In this case, count = 6
input = featureClass
output0 = r"C:\Users\TL\Desktop\812test\test\Route0"
arcpy.Select_analysis(input, output0, "{0} = 0".format(arcpy.AddFieldDelimiters(input,"FID")))
input = featureClass
output1 = r"C:\Users\TL\Desktop\812test\test\Route1"
arcpy.Select_analysis(input, output1, "{0} = 1".format(arcpy.AddFieldDelimiters(input,"FID")))
input = featureClass
output2 = r"C:\Users\TL\Desktop\812test\test\Route2"
arcpy.Select_analysis(input, output2, "{0} = 2".format(arcpy.AddFieldDelimiters(input,"FID")))
input = featureClass
output3 = r"C:\Users\TL\Desktop\812test\test\Route3"
arcpy.Select_analysis(input, output3, "{0} = 3".format(arcpy.AddFieldDelimiters(input,"FID")))
input = featureClass
output4 = r"C:\Users\TL\Desktop\812test\test\Route4"
arcpy.Select_analysis(input, output4, "{0} = 4".format(arcpy.AddFieldDelimiters(input,"FID")))
input = featureClass
output5 = r"C:\Users\TL\Desktop\812test\test\Route5"
arcpy.Select_analysis(input, output5, "{0} = 5".format(arcpy.AddFieldDelimiters(input,"FID")))
My original plan is to change the code like this, but it doesn't work. Any suggestions?
import arcpy
featureClass = r"C:\Users\TL\Desktop\812test\SplitAllRoutes_FacID\FacID1655.shp"
count = int(arcpy.GetCount_management(featureClass).getOutput(0)) # In this case, count = 6
for i in range(count):
input = featureClass
output%s = r"C:\Users\TL\Desktop\812test\test\Route%s" % (i, i)
arcpy.Select_analysis(input, output%s % i, "{0} = %s".format(arcpy.AddFieldDelimiters(input,"FID") % i))