Skip to content

Commit

Permalink
ENH: don't raise exception if HDF5 file is readonly, close #847
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Mar 15, 2012
1 parent 39efc7b commit 19bbb4a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@ def open(self, mode='a', warn=True):
self.complib,
fletcher32=self.fletcher32)

self.handle = _tables().openFile(self.path, self.mode)
try:
self.handle = _tables().openFile(self.path, self.mode)
except IOError, e: # pragma: no cover
if 'can not be written' in str(e):
print 'Opening %s in read-only mode' % self.path
self.handle = _tables().openFile(self.path, 'r')
else:
raise

def close(self):
"""
Expand Down

0 comments on commit 19bbb4a

Please sign in to comment.