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)
-
What do you mean by "register the results"? Locks are created on active tables. If it's still active, you shouldn't be able to delete it.Vince– Vince2022年06月03日 13:44:00 +00:00Commented Jun 3, 2022 at 13:44
-
I mean that i write numbers I get into a database. The temporary table is no more affected by my toolDavid Remotti– David Remotti2022年06月03日 14:19:15 +00:00Commented Jun 3, 2022 at 14:19
-
Where/how are you running this code? In the interactive Python window in Pro, in a Jupyter notebook in Pro, in a stand-alone Python session outside of Pro, etc...bixb0012– bixb00122022年06月03日 15:15:17 +00:00Commented Jun 3, 2022 at 15:15
-
my toolbox in ArcGis Desktop 10.3.1David Remotti– David Remotti2022年06月03日 15:46:10 +00:00Commented Jun 3, 2022 at 15:46
-
Does the code work on the first iteration through the loop and then fail after?bixb0012– bixb00122022年06月03日 18:54:55 +00:00Commented Jun 3, 2022 at 18:54
1 Answer 1
Unlocker is a great freeware utility that can delete application-locked files.