def extract_data_from_filename(filename):
    return extract_data_from_handle(hdf5.File(filename, 'r'))
for filename in files:
    data = extract_data_from_filename(filename)
for row in data:
    out_csv.writerow((filename,) + row)
Python HDF5 H5Py issues opening multiple files