-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Closed
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
When using pd.HDFStore methods directly the store often stays open. Especially in interactive context. That can cause some permission errors:
In [1]: pd.Series([1,2,3]).to_hdf('foo.h5', 'x')
In [2]: pd.Series([1,2,3]).to_hdf('foo.h5', 'y')
In [3]: pd.HDFStore('foo.h5', 'r').keys()
Out[3]: ['/x', '/y']
In [4]: pd.Series([1,2,3]).to_hdf('foo.h5', 'z')
ValueError: The file 'foo.h5' is already opened, but in read-only mode. Please close it before reopening in append mode.
In [5]: os.rename('foo.h5', 'bar.h5')
On Windows:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'foo.h5' -> 'bar.h5'
Feature Description
Adding destructor solves this
pd.io.pytables.HDFStore.__del__ = lambda self: self.close()
Alternative Solutions
.
Additional Context
No response
Metadata
Metadata
Assignees
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member