-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Conversation
its only open/closed automatically when you use |
@seanyeh anything further? otherwise pls close |
I do find it odd that it allows an option that doesn't work. Thanks anyway |
where does the option not work? it works exactly how its supposed to in How else would you expect it to work? |
@jreback what's the point of passing iterator=True if you can't iterate over the result? It seems intuitive that this should work, right? for x in pandas.read_hdf("test.h5", "test", iterator=True):
print x but according to the example above, that would raise the closed node error. Maybe it would make more sense to have TableIterator handle the cleanup if |
@jtratner @seanyeh I guess if the context manager is passed an open handle then it shouldn't close it... |
+1 for enabling read_hdf(..., iterator=True). Arguably, since pytables automatically closes the h5 file via atexit.register(close_open_files), we don't need to explicitly close it. |
@adgaudio I disagree. These files need explicit open/close; or use with a context manager. ] This is straightforward to address and will be fixed soon. Relying on the system to close files is not good from a safety perspective nor good programming practice. |
Yea, true. Thanks everyone - I'll look forward to using the patch :) |
Agree with @jreback. atexit is fragile and there's no reason not to handle On a separate note - @is it problematic to pass (or set) a reference to the @adgaudio https://github.com/adgaudio I disagree. These files need explicit open/close; or use with a context manager. ] This is straightforward to address and will be fixed soon. Relying on the system to close files is not good from a safety perspective — |
Okay, this is great! thanks! |
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:
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