Skip to content

allow HDFStore to remain open when TableIterator is returned from read_hdf #3937

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def h5_open(path, mode):

@contextmanager
def get_store(path, mode='a', complevel=None, complib=None,
fletcher32=False):
fletcher32=False, iterator=False):
"""
Creates an HDFStore instance. This function can be used in a with statement

Expand All @@ -175,7 +175,7 @@ def get_store(path, mode='a', complevel=None, complib=None,
complib=complib, fletcher32=False)
yield store
finally:
if store is not None:
if store is not None and not iterator:
store.close()


Expand All @@ -199,7 +199,7 @@ def read_hdf(path_or_buf, key, **kwargs):
f = lambda store: store.select(key, **kwargs)

if isinstance(path_or_buf, basestring):
with get_store(path_or_buf) as store:
with get_store(path_or_buf, iterator=kwargs.get("iterator")) as store:
return f(store)
f(path_or_buf)

Expand Down