question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError when opening a read-only hdf twice

See original GitHub issue
In [3]: with pd.HDFStore('/tmp/file_I_can_only_read.hdf') as store:
   ...:     store['test'] = pd.Series(range(3))
   ...:     

In [4]: os.chmod('/tmp/file_I_can_only_read.hdf', 0o400)

In [5]: store1 = pd.HDFStore('/tmp/file_I_can_only_read.hdf')
Opening /tmp/file_I_can_only_read.hdf in read-only mode

In [6]: store2 = pd.HDFStore('/tmp/file_I_can_only_read.hdf')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-5b173bb4a3e8> in <module>()
----> 1 store2 = pd.HDFStore('/tmp/file_I_can_only_read.hdf')

/home/pietro/nobackup/repo/pandas/pandas/io/pytables.py in __init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
    402         self._fletcher32 = fletcher32
    403         self._filters = None
--> 404         self.open(mode=mode, **kwargs)
    405 
    406     @property

/home/pietro/nobackup/repo/pandas/pandas/io/pytables.py in open(self, mode, **kwargs)
    563                             hdf_version=tables.get_hdf5_version()))
    564 
--> 565             raise e
    566 
    567         except (Exception) as e:

/home/pietro/nobackup/repo/pandas/pandas/io/pytables.py in open(self, mode, **kwargs)
    538 
    539         try:
--> 540             self._handle = tables.open_file(self._path, self._mode, **kwargs)
    541         except (IOError) as e:  # pragma: no cover
    542             if 'can not be written' in str(e):

/usr/lib/python3/dist-packages/tables/file.py in open_file(filename, mode, title, root_uep, filters, **kwargs)
    308                     "The file '%s' is already opened, but "
    309                     "in read-only mode.  Please close it before "
--> 310                     "reopening in append mode." % filename)
    311             # 'w' means that we want to destroy existing contents
    312             elif mode == 'w':

ValueError: The file '/tmp/file_I_can_only_read.hdf' is already opened, but in read-only mode.  Please close it before reopening in append mode.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jrebackcommented, Feb 9, 2016

it’s much better to have an explicit error

0reactions
toobazcommented, Feb 9, 2016

The default on read-only stores is read, but as you prefer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Close HDF File After to_hdf() using mode='a' - Stack Overflow
I want to save a series of DataFrame using pandas into hdf file. ... The file 'append.h5' is already opened, but not in...
Read more >
Source code for tables.file - PyTables
'r': raise ValueError( "The file '%s' is already opened, but " "not in read-only mode (as requested)." % filename) # 'a' and 'r+'...
Read more >
IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
Row number(s) to use as the column names, and the start of the data. Default behavior is to infer the column names: if...
Read more >
1156354 – ValueError: cannot modify protected device
First of all, I twice tried guided partitioning. I saw an error on the main hub, but when I entered the storage spoke,...
Read more >
pysam documentation - Read the Docs
ValueError – if htsfile is closed or index could not be opened. ... The first level contains the record (HD, SQ, etc) and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found