rxn.utilities.files.stable_shuffle

rxn.utilities.files.stable_shuffle(input_file, output_file, seed, is_csv=False)[source]

Shuffle a file in a deterministic order (the same seed always reorders files of the same number of lines identically).

Useful, as an example, to shuffle a source and target files identically.

Parameters
  • input_file (Union[str, PathLike]) – file to shuffle.

  • output_file (Union[str, PathLike]) – where to save the shuffled file.

  • is_csv (bool, default: False) – if True, the first line will not be shuffled.

  • seed (int) –

Return type

None