Skip to content

Commit d9e4969

Browse files
committed
Open HDF5 file in ro mode if no other mode was passed.
Currently the `HDFStore` is opened in `rw` mode by default, leading to permission errors when reading a non-writeable file.
1 parent 8ef921f commit d9e4969

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

doc/source/whatsnew/v0.16.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,4 @@ Bug Fixes
344344
- Bug in groupby MultiIndex with missing pair (:issue:`9049`, :issue:`9344`)
345345
- Fixed bug in ``Series.groupby`` where grouping on ``MultiIndex`` levels would ignore the sort argument (:issue:`9444`)
346346
- Fix bug in ``DataFrame.Groupby`` where sort=False is ignored in case of Categorical columns. (:issue:`8868`)
347+
- Fix issue on when reading HDF5 files using ``read_hdf`` from a Windows file share without write-permissions. (:issue:`9551`)

pandas/io/pytables.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def read_hdf(path_or_buf, key, **kwargs):
318318

319319
# can't auto open/close if we are using an iterator
320320
# so delegate to the iterator
321+
kwargs.setdefault("mode", "r")
321322
store = HDFStore(path_or_buf, **kwargs)
322323
try:
323324
return f(store, True)

0 commit comments

Comments
 (0)