1

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
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 1, 2016 at 23:04
2
  • 1
    Have you tried doing a print('Value_' + str(i), "TotalCT" + "= %d" % value) to see what it is passing for the where clause? 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. Commented Sep 2, 2016 at 0:16

1 Answer 1

2

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.

answered Sep 1, 2016 at 23:10
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.