Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
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 '12 at 18:19
add comment

2 Answers 2

up vote 12 down vote accepted

As seen in this question, I believe you should use the Delete Tool to remove a table view once it has been created.

arcpy.Delete_management(tblView)

share|improve this answer
    
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 '12 at 18:49
add comment

arcpy.env.overwriteOutput = True

share|improve this answer
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. –  Devdatta Tengshe Jan 15 '13 at 16:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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