OSError: Unable to open file (File signature not found)

See original GitHub issue

I think this is the same bug as #142.

I am trying to load a MATLAB generated data file into Jupyter using h5py. The file definitely exists. Is this also an older HDF4 format? How can I tell?

import numpy as np, h5py 
import os.path

filename1 = r"input\train_1\1_1_0.mat"

if os.path.isfile(filename1) and os.access(filename1, os.R_OK):
    f = h5py.File(filename1,'r') 
else:
    print("Either file is missing or is not readable")

And the error:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-21-dc964679d992> in <module>()
      5 
      6 if os.path.isfile(filename1) and os.access(filename1, os.R_OK):
----> 7     f = h5py.File(filename1,'r')
      8 else:
      9     print("Either file is missing or is not readable")

C:\Users\reina\Anaconda3\lib\site-packages\h5py\_hl\files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds)
    270 
    271                 fapl = make_fapl(driver, libver, **kwds)
--> 272                 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
    273 
    274                 if swmr_support:

C:\Users\reina\Anaconda3\lib\site-packages\h5py\_hl\files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
     90         if swmr and swmr_support:
     91             flags |= h5f.ACC_SWMR_READ
---> 92         fid = h5f.open(name, flags, fapl=fapl)
     93     elif mode == 'r+':
     94         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py\_objects.pyx in h5py._objects.with_phil.wrapper (C:\aroot\work\h5py\_objects.c:2579)()

h5py\_objects.pyx in h5py._objects.with_phil.wrapper (C:\aroot\work\h5py\_objects.c:2538)()

h5py\h5f.pyx in h5py.h5f.open (C:\aroot\work\h5py\h5f.c:1813)()

OSError: Unable to open file (File signature not found)

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

20reactions
Rajat-Mehtacommented, Aug 11, 2018

I was facing the same issue with my .h5 file. And the problem was that I was not downloading the .h5 file correctly.

I was doing filename.h5->right_click->save link as, which was not downloading the file correctly(or may be the file was getting corrupted). Instead of doing that I downloaded the file as : selected the checkbox with filename.h5 and clicked on download and after that my code worked.

May be this help the one’s who are doing the same mistake.

13reactions
mxbicommented, Nov 24, 2018

For reference: for anyone else getting this issue with a .mat file, it is likely because the file was generated with an older version of MATLAB before it was switched over to using HDF5. See https://stackoverflow.com/questions/4950630/matlab-differences-between-mat-versions

The solution for these older mat files is to read it with something like scipy.io.loadmat: https://docs.scipy.org/doc/scipy-0.19.0/reference/generated/scipy.io.loadmat.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error opening file in H5PY (File signature not found)
Usually the message File signature not found indicates either: 1. Your file is corrupted. ... is what I think is most likely.
Read more >
OSError: Unable to open file (file signature not found) - Streamlit
OSError : Unable to open file (file signature not found). Traceback:
Read more >
OSError: Unable to open file (file signature not found)
OSError: Invalid decryption. Unable to open file (file signature not found). The key used to load the model is incorrect.
Read more >
ioerror: unable to open file (file signature not found) keras
I have come across the same issue and have tracked down the problem - but no idea how to fix it Basically the...
Read more >
Error opening file in H5PY (File signature not found)
Usually this happens when files are corrupted. I faced this problem and downloaded the file again and it resolves the issues. Dharmendra Singh...
Read more >

github_iconTop Related Medium Post

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