Unable to open .hdf file using h5py in Python

625 views Asked by At

OSError: Unable to open file (file signature not found) My code

I feel that the problem is .hdf file as I don't have .h5 or .hdf5 file. So how to I open .hdf in python?

1

There are 1 answers

0
Raphael On

You can check if the file is HDF4 format with this program:
https://www.hdfgroup.org/downloads/hdfview/

HDF4 files can be opened in python according to this tutorial:
https://hdfeos.org/software/pyhdf.php

from pyhdf.SD import SD, SDC

file_name = 'thefilename.hdf'
file = SD(file_name, SDC.READ)

print file.info()