The following picture shows the table for the shapefile. I need to extract those rows with different values of TotalCT, which means I need to extract the first row into a new shapefile named Value_1.shp, and extract the second and third rows into another new shapefile named Value_2.shp. I wrote the below code, but it gave me the empty shapefiles. Any suggestions? enter image description here
casefile = r"C:\Users\TL\Desktop831円test913円\FULLNAME_Atlanta_Park_Rd.shp"
outputfolder = r"C:\Users\TL\Desktop831円test\casefile"
ValueCT = unique_values(casefile, field)
i = 1
field = "TotalCT"
for value in ValueCT:
arcpy.FeatureClassToFeatureClass_conversion(casefile, outputfolder, 'Value_' + str(i), "TotalCT" + "= %d" % value)
i += 1
1 Answer 1
Instead of:
arcpy.FeatureClassToFeatureClass_conversion(casefile, outputfolder, 'Value_' + str(i), "TotalCT" + "= %d" % value)
perhaps try:
arcpy.FeatureClassToFeatureClass_conversion(casefile, outputfolder, 'Value_{0}'.format(i), "TotalCT = {0}".format(value))
The way that I have suggested uses the Python str.format() method which I prefer to its predecessor.
print('Value_' + str(i), "TotalCT" + "= %d" % value)
to see what it is passing for the where clause?