From fa435dc73c3ec4dd4e4d816304b7f1abdb41b8bf Mon Sep 17 00:00:00 2001 From: Sean Yeh Date: Mon, 17 Jun 2013 15:37:07 -0400 Subject: [PATCH] allow HDFStore to remain open when TableIterator is returned from read_hdf --- pandas/io/pytables.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 62aa1b99dfac0..34dddc03cc072 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -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 @@ -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() @@ -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)