Corrupt files when creating HDF5 files without closing them (h5py)

末鹿安然 提交于 2019-12-01 19:31:55

The corruption problem is known to the HDF5 designers. They are working on fixing this in version 1.10 by adding journalling. In the mean time you can call flush() periodically to make sure your writes have been flushed, which should minimise some of the damage. You can also try to use external links which will allow you to store pieces of data in separate files but link them together into one structure when you read them.

Nothing will prevent a file from being corrupted in the event of e.g. a power outage. All you can do is minimize damage. One way to do this is using redundancy. You use two files instead of one, and only one of those is opened at any time. Say file 1 is opened, you write all your changes to file 1. After a certain amount of time or a certain amount of data written, close it, update file 2 from file one, and continue writing to file 2 and so on alternating.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!