Невозможно установить имя набора данных в файле hdf5 путем нарезки - PullRequest
1 голос
/ 16 июня 2019

Я пытаюсь сохранить 3 набора данных в файле hdf5, используя команду h5py. Имя каждого набора данных выделяется срезом, но это не работает.


# First I open a .png image file and convert this image to an numpy array
# called "raster":
.
.
.
# The second step is, that i'm trying to extract the datasetname by a slicing
# on the filename to give the dataset a name:

filename = imagefile1.png

dsetName = filename[:-4]

# Then i open a hdf5 file by:

file = h5py.File('hdf5_file.5h', 'a')

# and write the dataset into that file:

file.create_dataset(dsetName, data=raster)

Но в этот момент я всегда сталкиваюсь с одной и той же проблемой:

AttributeError: у объекта 'slice' нет атрибута 'encode'

...