arcpy.Delete_management not working on particular shpfiles.

852
2
04-24-2018 12:57 PM
ShaneStevenson
New Contributor

Hi folks, I've been stuck on this for ages. Hopefully someone might have some tips. I have some code to delete a .shp file.

arcpy.env.workspace = "C:/check"
ws = arcpy.env.workspace
in_data = "Folklore.shp"
data_type = ""

arcpy.env.overwriteOutput = True
arcpy.Delete_management(in_data, data_type)
arcpy.Delete_management('Folklore.shp')

The shp file just won't delete. It seems to make it stop working but not delete. It is a points shp file. This code works fine if I delete a polygon shp file. So I don't think it is a problem with the code. Does anybody know of any particular issues with deleting certain types of shp files. There are no lock files. And ArcMAP and ArcCatalog are closed.

Thanks

Tags (1)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

from here... http://pro.arcgis.com/en/pro-app/tool-reference/data-management/delete.htm

import arcpy
arcpy.env.workspace = "C:/check"
arcpy.Delete_management('Folklore.shp')

of course the folder and the shape file must exist.  If there was a lock, then you would get an error.

You may need to refresh your views in Windows  to see changes and/or in whatever you are using to check to see if it is gone.

 

RandyBurton
MVP Alum

Is it possible that the file's read-only attribute has been set?