14

In a Python script, I'm cycling through thousands of Excel files and using arcpy.MakeTableView to create in memory table views from the first spreadhseet in each file. How do you delete the reference to the in-memory view? I've tried deleting the variable that stores the table name, but to no avail.

tblView = sheetName
arcpy.MakeTableView_management(excelSheet, tblView, .....)
## Process the table here
del tblView

The reason for deleting the reference is that in some cases the sheet names are duplicated in the Excel files. If a table view has been created with the name "Sheet1", you can't create another table view with the same name. In addition, due to the number and size of the Excel files being processed, I'm concerned about an impact on performance if all of those table views are preserved through the life of the script.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Feb 21, 2012 at 18:12
1
  • Just as a side note, I can assign a different name to the table view that is not based on the sheet name and loop through the files without conflicts. However, I would still like to know how to delete the in-memory reference. Commented Feb 21, 2012 at 18:19

2 Answers 2

17

As seen in Removing feature layer using ArcPy script?, I believe you should use the Delete Tool to remove a table view once it has been created.

arcpy.Delete_management(tblView)
answered Feb 21, 2012 at 18:43
1
  • I actually had looked at that question, but didn't think it applied. But after trying it, it does indeed work on an in-memory table view. Should have tried it before posting. Thanks Nathanus. Commented Feb 21, 2012 at 18:49
1

arcpy.env.overwriteOutput = True

answered Jan 15, 2013 at 15:32
1
  • 1
    This would only overwrite the table with a new one, if the new process outputs a table of the same name. It will not delete an In-memory table specifically. Commented Jan 15, 2013 at 16:41

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.