0

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)

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 3, 2022 at 13:18
6
  • 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. Commented 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 tool Commented 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... Commented Jun 3, 2022 at 15:15
  • my toolbox in ArcGis Desktop 10.3.1 Commented Jun 3, 2022 at 15:46
  • Does the code work on the first iteration through the loop and then fail after? Commented Jun 3, 2022 at 18:54

1 Answer 1

-3

Unlocker is a great freeware utility that can delete application-locked files.

answered Jun 3, 2022 at 15:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.