bmgustafson

Selecting Data

Discussion created by bmgustafson on Jun 26, 2011
Latest reply on Jun 27, 2011 by mdenil
When I run the SelectLayerByAttribute_management method it says that I have invalid arguments, this tool cannot be run on a feature class.  When I run it in arcmap it works on one of the shapefiles I am trying to edit.  what I am trying to do is select a set of data in a list of shapefiles and delete it.  Is the code below what I need to do what I want on a SHP?

import arcpy
from arcpy import env
import os

env.workspace = "C:/Users/brigus/Desktop/Staging_UHF"

fcs = arcpy.ListFeatureClasses()

#Define FC Projection
#for fc in fcs:
    #arcpy.DefineProjection_management(fc, "C:/Program Files (x86)/Desktop10.0/Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj")
    #print fc + " is defined."


#Delete data that is < 28 BDU
where = "DBU_FIELD < 28"

for fc in fcs:
    arcpy.SelectLayerByAttribute_management(fc, "NEW_SELECTION", where)
    #if int(arcpy.GetCount_management(fc).getOutput(0)) > 0:
        #arcpy.DeleteFeatures_management(fc)
    print fc + " is ready to load."

Outcomes