У меня небольшой (<6Mb) файл <code>.hdf (полученный из сервиса LAADS DAA C). Я пытался pandas
и h5py
открыть его, но безрезультатно (код показан ниже). Я также проверил файл с:
$ h5dump -n data.hdf
h5dump error: unable to open file "data.hdf"
и
$ h5debug data.hdf
cannot open file
Казалось бы, все это указывает на поврежденный файл, но странная вещь в том, что HDF View (v2.11) имеет абсолютно никаких проблем с открытием этого файла .
Что здесь происходит?
1.
import h5py
data = h5py.File(filename, 'r')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/h5py/_hl/files.py", line 394, in __init__
swmr=swmr)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/h5py/_hl/files.py", line 170, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 85, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
2.
import pandas as pd
data = pd.io.pytables.read_hdf(filename)
Traceback (most recent call last):
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/io/pytables.py", line 603, in open
self._handle = tables.open_file(self._path, self._mode, **kwargs)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/tables/file.py", line 320, in open_file
return File(filename, mode, title, root_uep, filters, **kwargs)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/tables/file.py", line 784, in __init__
self._g_new(filename, mode, **params)
File "tables/hdf5extension.pyx", line 492, in tables.hdf5extension.File._g_new
tables.exceptions.HDF5ExtError: HDF5 error back trace
File "H5F.c", line 511, in H5Fopen
unable to open file
File "H5Fint.c", line 1604, in H5F_open
unable to read superblock
File "H5Fsuper.c", line 413, in H5F__super_read
file signature not found
End of HDF5 error back trace
Unable to open/create file 'data.hdf'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/io/pytables.py", line 368, in read_hdf
store = HDFStore(path_or_buf, mode=mode, **kwargs)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/io/pytables.py", line 488, in __init__
self.open(mode=mode, **kwargs)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/io/pytables.py", line 636, in open
raise IOError(str(e))
OSError: HDF5 error back trace
File "H5F.c", line 511, in H5Fopen
unable to open file
File "H5Fint.c", line 1604, in H5F_open
unable to read superblock
File "H5Fsuper.c", line 413, in H5F__super_read
file signature not found
End of HDF5 error back trace
Unable to open/create file 'data.hdf'
3.
import pandas as pd
data = pd.HDFStore(filename, mode='r')
Traceback (most recent call last):
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/io/pytables.py", line 603, in open
self._handle = tables.open_file(self._path, self._mode, **kwargs)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/tables/file.py", line 320, in open_file
return File(filename, mode, title, root_uep, filters, **kwargs)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/tables/file.py", line 784, in __init__
self._g_new(filename, mode, **params)
File "tables/hdf5extension.pyx", line 492, in tables.hdf5extension.File._g_new
tables.exceptions.HDF5ExtError: HDF5 error back trace
File "H5F.c", line 511, in H5Fopen
unable to open file
File "H5Fint.c", line 1604, in H5F_open
unable to read superblock
File "H5Fsuper.c", line 413, in H5F__super_read
file signature not found
End of HDF5 error back trace
Unable to open/create file 'data.hdf'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/io/pytables.py", line 488, in __init__
self.open(mode=mode, **kwargs)
File "/home/gabriel/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/io/pytables.py", line 636, in open
raise IOError(str(e))
OSError: HDF5 error back trace
File "H5F.c", line 511, in H5Fopen
unable to open file
File "H5Fint.c", line 1604, in H5F_open
unable to read superblock
File "H5Fsuper.c", line 413, in H5F__super_read
file signature not found
End of HDF5 error back trace
Unable to open/create file 'data.hdf'