首页 > 解决方案 > h5py causes jupyter to crash in for loop

问题描述

I am using a for loop to load arrays with different names into a h5py file. The goal is to load matlab files as python files from each independent folder, then to store all these loaded arrays into a h5py file.

Code:

with h5py.File("Filename.hdf5", 'w') as f:
    for i in Data_names:
        try:
            f.create_dataset(str(i), data = scipy.io.loadmat('./folder/' + str(i) + '/wantedfile.mat'))
        except IOError:
            pass

The code seems to work for the first 6 values of i, then starts to glitch. One of the error is a file save error and this also causes problems with opening any of my other notebooks.

Is the error in that the h5py file is too large? or is the problem an error with my for loop?

标签: pythonh5py

解决方案


推荐阅读