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.

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.
    – Jeff Berry
    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)
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.
    – Jeff Berry
    Feb 21, 2012 at 18:49
1

arcpy.env.overwriteOutput = True

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. Jan 15, 2013 at 16:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.