pydata/pandas — pull request #3937 by seanyeh (2013-06-17 19:45:39+00:00)
Title: allow HDFStore to remain open when TableIterator is returned from read_hdf

Hi,
I'm using a TableIterator from pandas.read_hdf function (with the keyword argument iterator=True), I am unable to retrieve any data due to the error "ClosedNodeError: the node object is closed".

For instance:

pandas.DataFrame({'a':[1,2,3], 'b':[4,5,6]}).to_hdf("test.h5", "test", append=True)
it = pandas.read_hdf("test.h5","test",iterator=True)
iter(it).next()

Traceback (most recent call last):
File "", line 1, in
iter(it).next()
File "/usr/local/lib/python2.7/site-packages/pandas/io/pytables.py", line 912, in __iter__
v = self.func(current, stop)
...
File "/usr/local/lib/python2.7/site-packages/tables/node.py", line 355, in _g_check_open
raise ClosedNodeError("the node object is closed")
ClosedNodeError: the node object is closed

I looked through source code of panda.io.pytables and found that in the
get_store function, store.close() is always run when read_hdf returns, even if
it returns an TableIterator. My assumption is that store should remain open in
order for TableIterator to work. Can you please let me know if this fix is
acceptable, or is there an easier way to do this?

Thanks,
Sean