code: def tohdf5(input_files, output_file, n_events, conv_times_to_jte, **kwargs):
      
      if len(input_files) > 1:
          cprint(
              "Preparing to convert {} files to HDF5.".format(len(input_files))
          )
  
      from km3pipe import Pipeline    # noqa
      from km3pipe.io import GenericPump, HDF5Sink, HDF5MetaData    # noqa
  
      for input_file in input_files:
          cprint("Converting '{}'...".format(input_file))
          if len(input_files) > 1:
              output_file = input_file + '.h5'
  
          meta_data = kwargs.copy()
          meta_data['origin'] = input_file
  
          pipe = Pipeline()
          pipe.attach(HDF5MetaData, data=meta_data)
          pipe.attach(GenericPump, filenames=input_file, **kwargs)
          pipe.attach(StatusBar, every=250)
          if conv_times_to_jte:
              from km3modules.mc import MCTimeCorrector
              pipe.attach(MCTimeCorrector)
          pipe.attach(HDF5Sink, filename=output_file, **kwargs)
          pipe.drain(n_events)
          cprint("File '{}' was converted.".format(input_file))
docs: Convert Any file to HDF5 file