首页 > 解决方案 > 如何处理无法打开的 HDF5 文件

问题描述

我正在使用 Python h5py 库,我不是 C/C++ 程序员。

我有一个文件无法读取,因为创建数据集的长写入操作被中断。

如果可能的话,我希望能够打开文件并删除损坏的数据集,以便我可以重新加载它而不会丢失所有其他数据。

我尝试使用给定的错误消息在以下 HDF5 实用程序中打开该文件。

INFO    pydap.request:39 > Opening file:///C:\Users\HIAPRC\Documents\CH149\One_off_code\hdf5_check\test.h5.dds
DEBUG   hdf_compass.opendap_model.model.can_handle:61 > able to handle file:///C:\Users\HIAPRC\Documents\CH149\One_off_code\hdf5_check\test.h5? no
DEBUG   hdf_compass.asc_model.model.can_handle:74 > able to handle file:///C:\Users\HIAPRC\Documents\CH149\One_off_code\hdf5_check\test.h5? no, missing .asc extension
Traceback (most recent call last):
  File "c:\users\john\hdf-compass\hdf_compass\compass_viewer\frame.py", line 199, in on_file_open
  File "c:\users\john\hdf-compass\hdf_compass\compass_viewer\frame.py", line 223, in open_url
  File "c:\users\john\hdf-compass\hdf_compass\compass_viewer\viewer.py", line 175, in can_open_store
  File "c:\users\john\hdf-compass\hdf_compass\bag_model\model.py", line 88, in can_handle
  File "site-packages\hydroffice\bag\base.py", line 31, in is_bag
  File "site-packages\h5py\_hl\files.py", line 272, in __init__
  File "site-packages\h5py\_hl\files.py", line 92, in make_fid
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (C:\aroot\work\h5py\_objects.c:2587)
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (C:\aroot\work\h5py\_objects.c:2546)
  File "h5py\h5f.pyx", line 76, in h5py.h5f.open (C:\aroot\work\h5py\h5f.c:1821)
IOError: Unable to open file (Bad object header version number)

任何有关如何进行的线索将不胜感激。提前致谢。

标签: pythonhdf5h5py

解决方案


推荐阅读