I am trying to copy specific attribute table rows from one shapefile to a new shapefile that will contain only the specified rows in its attribute table, that is, if a field GDP_TOP10 = 1
.
I am using this at the moment:
#Grab rows using Search Cursor with WHERE clause
rows = arcpy.SearchCursor("C:/CGDP.shp", "GDP_TOP10 = 1")
for row in rows:
arcpy.CopyFeatures_management("CGDP.shp", "New.shp")
del row
del rows
However, this just copies the entire shapefile, not the rows I want to select with the cursor. If I execute a print statement under my for loop instead, it works and prints only the relevant fields, but the copy to new shapefile command does not seem to copy specifically.
Is there a different ArcPy command to only copy rows that match a query?