#!/usr/bin/env python3 import h5py from numpy import loadtxt from sys import argv with h5py.File("collect.h5","w") as h5: for afile in argv[1:]: print(afile) data = loadtxt(afile) # here is the data type an intt64, could be also Float64 (f), int32 (i8), etc. dataset = h5.create_dataset(f"{afile}", data=data, compression='gzip', shuffle=True, dtype="i") # example for an attribute for this dataset (the original filename) dataset.attrs["filename"] = afile h5.close() # do not forget to delete the files