Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

deleting used files

$
0
0
The code works, I just want to be able to delete the intersected output.shp and the frequency table once the code finishes looping through the featureclasses. I tried doing a Delete_management but it terminated the code after printing the first feature class. Any ideas how to dynamically execute the file cleanup?


Code:

                      arcpy.env.workspace= workspace
                        arcpy.env.OverwriteOutput = True
                        lstfc = sorted(arcpy.ListFeatureClasses())
                        for fc in lstfc:
                            arcpy.Intersect_analysis([fc,intersected feature class],path to intersected output.shp)
                            arcpy.MakeFeatureLayer_management(path to intersected output.shp,"fclayer","PERSON='' OR PERSON IS NULL")
                            arcpy.Frequency_analysis("fclayer",path to frequency table,["PERSON_1"])
                            lststate=set([row.getValue("PERSON_1") for row in arcpy.SearchCursor(path to frequency table)])
                            newlist=sorted(lststate)
                            for state in newlist:
                                print state + " " + fc


Viewing all articles
Browse latest Browse all 2485

Trending Articles