matrix_translation_from_file#

caf.toolkit.translation.matrix_translation_from_file(matrix_path, translation_path, output_path, *, matrix_zone_columns, matrix_values_column, translation_from_column, translation_to_column, translation_factors_column, format_='long')[source]#

Translate zoning system of matrix CSV file.

Load matrix from CSV, perform translation and write to new CSV. CSV files are expected to be in the matrix ‘long’ format.

Parameters:
  • matrix_path (pathlib.Path) – Path to matrix CSV file.

  • translation_path (pathlib.Path) – Path to translation lookup CSV.

  • output_path (pathlib.Path) – CSV path to save the translated data to.

  • matrix_zone_columns (tuple[int | str, int | str]) – Names, or positions, of the 2 columns containing the zone IDs in the matrix file.

  • matrix_values_column (int | str) – Name, or position, of the column containing the matrix values.

  • translation_from_column (int | str) – Name, or position, of zone ID column in translation which corresponds to the current vector zone ID.

  • translation_to_column (int | str) – Name, or position, of column in translation for the new zone IDs.

  • translation_factors_column (int | str) – Name, or position, of column in translation containing the splitting factors.

  • format (Literal["square", "long"] = "long",) – Whether the matrix is in long or wide format.

  • format_ (Literal['square', 'long'])

Return type:

None