I have a Python tool to calculate some simple statistics on a lot of features. I use arcpy.Statistics_analysis to create a DBF file with stats for a feature class, register the results, then pass to the following.
So I would like to use a temporary file for each feature class, then delete it before passing to the next.
Unfortunately this temporary file seems impossible to delete, also if I use arcpy.env.overwriteOutput = True
Any hint ?
here is my code
for fc in arcpy.ListFeatureClasses(feature_type='polygon'):
if arcpy.Exists(outFolder + os.sep + "appo.dbf"):
arcpy.Delete_management(outFolder + os.sep + "appo.dbf")
arcpy.Statistics_analysis(fc, outFolder + os.sep + "appo.dbf", [["Ettari", "SUM"]])
the error message is
ExecuteError: ERROR 000601: Cannot delete C:\Terna\Connessioni\appo\appo.dbf. May be locked by another application.
Failed to execute (Delete)