Skip to content

ENH: clearer error message if read_hdf loads upsupported HDF file (GH9539) #33509

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 7 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ Other enhancements
This can be used to set a custom compression level, e.g.,
``df.to_csv(path, compression={'method': 'gzip', 'compresslevel': 1}``
(:issue:`33196`)
- :func:`pandas.read_hdf` has a more explicit error message when loading an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move to the IO section

unsupported HDF file (:issue:`9539`)

.. ---------------------------------------------------------------------------

Expand Down
5 changes: 4 additions & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,10 @@ def read_hdf(
if key is None:
groups = store.groups()
if len(groups) == 0:
raise ValueError("No dataset in HDF5 file.")
raise ValueError(
"Dataset that is either compatible with Pandas data types "
"or is a table could not be found in HDF5 file."
)
candidate_only_group = groups[0]

# For the HDF file to have only one dataset, all other groups
Expand Down