I tried recording a selection using first
arcpy.SelectLayerByAttribute_management and then
'arcpy.CopyFeatures_management' but since my input was a feature class I get an error. So, I converted my input into a .lyr and now my output is empty when I open it in Arcgis.
import arcpy arcpy.env.workspace = "C:/Temp/PyData" shpfile = 'building_split.shp' arcpy.MakeFeatureLayer_management(in_features=shpfile, out_layer="bui_lyr") lyr = 'bui_lyr' arcpy.SelectLayerByAttribute_management(in_layer_or_view=lyr, selection_type= "SUBSET_SELECTION", where_clause= '"length" > 25') arcpy.CopyFeatures_management(in_features=lyr, out_feature_class= 'res_building_25')
Here is my code, I guess there is a simple mistake somewhere I just began writing scripts in Python. Also, how can I perform a selection on my feature class. I guess I am not obliged to go through the creation of a .lyr file.
Edit: I did another try with a simpler code below, the test.shp file remains empty
import arcpy arcpy.env.workspace = "C:/Temp/PyData" arcpy.MakeFeatureLayer_management("building_split.shp", "bui_lyr") arcpy.SelectLayerByAttribute_management("bui_lyr", "SUBSET_SELECTION", "length > 25") arcpy.CopyFeatures_management("bui_lyr", "C:/Temp/PyData/Test.shp")