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\Desktop\831test\913\FULLNAME_Atlanta_Park_Rd.shp"
outputfolder = r"C:\Users\TL\Desktop\831test\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
    Have you tried doing a print('Value_' + str(i), "TotalCT" + "= %d" % value) to see what it is passing for the where clause?
    – Midavalo
    Commented Sep 1, 2016 at 23:31
  • Thank a bunch! I did what your suggest and noticed that the %d force the values to integer rather than float. However, there are still problems, and I can't get what I want.
    – Tianxin Li
    Commented Sep 2, 2016 at 0:16

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.