Skip to content

API/ENH: pass thru store creation arguments for HDFStore; can be used to support in-memory stores #5499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ API Changes
- ``flush`` now accepts an ``fsync`` parameter, which defaults to ``False``
(:issue:`5364`)
- ``unicode`` indices not supported on ``table`` formats (:issue:`5386`)
- pass thru store creation arguments; can be used to support in-memory stores
- ``JSON``

- added ``date_unit`` parameter to specify resolution of timestamps.
Expand Down
1 change: 1 addition & 0 deletions doc/source/v0.13.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ HDFStore API Changes
- add the keyword ``dropna=True`` to ``append`` to change whether ALL nan rows are not written
to the store (default is ``True``, ALL nan rows are NOT written), also settable
via the option ``io.hdf.dropna_table`` (:issue:`4625`)
- pass thru store creation arguments; can be used to support in-memory stores

Enhancements
~~~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def __init__(self, path, mode=None, complevel=None, complib=None,
self._complib = complib
self._fletcher32 = fletcher32
self._filters = None
self.open(mode=mode)
self.open(mode=mode, **kwargs)

@property
def root(self):
Expand Down Expand Up @@ -465,7 +465,7 @@ def items(self):

iteritems = items

def open(self, mode='a'):
def open(self, mode='a', **kwargs):
"""
Open the file in the specified mode

Expand Down Expand Up @@ -502,11 +502,11 @@ def open(self, mode='a'):
fletcher32=self._fletcher32)

try:
self._handle = tables.openFile(self._path, self._mode)
self._handle = tables.openFile(self._path, self._mode, **kwargs)
except (IOError) as e: # pragma: no cover
if 'can not be written' in str(e):
print('Opening %s in read-only mode' % self._path)
self._handle = tables.openFile(self._path, 'r')
self._handle = tables.openFile(self._path, 'r', **kwargs)
else:
raise
except (Exception) as e:
Expand Down
22 changes: 22 additions & 0 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,28 @@ def test_reopen_handle(self):
store.close()
self.assert_(not store.is_open)

def test_open_args(self):

with ensure_clean_path(self.path) as path:

df = tm.makeDataFrame()

# create an in memory store
store = HDFStore(path,mode='a',driver='H5FD_CORE',driver_core_backing_store=0)
store['df'] = df
store.append('df2',df)

tm.assert_frame_equal(store['df'],df)
tm.assert_frame_equal(store['df2'],df)

store.close()

# only supported on pytable >= 3.0.0
if LooseVersion(tables.__version__) >= '3.0.0':

# the file should not have actually been written
self.assert_(os.path.exists(path) is False)

def test_flush(self):

with ensure_clean_store(self.path) as store:
Expand Down