actio_python_utils.utils.get_csv_fields

actio_python_utils.utils.get_csv_fields(fn, sep=',', sanitize=False, sanitize_with=(('.', '_'), ('-', '_')))[source]

Get the column names from the first line of the specified file and optionally replaces an arbitrary sequence of strings to others

Parameters:
  • fn (str) – The path to the CSV to get column names from

  • sep (str, default: ',') – The field separator

  • sanitize (bool, default: False) – Whether to apply the string replacements in sanitize_with

  • sanitize_with (Optional[Iterable[tuple[str, str]]], default: (('.', '_'), ('-', '_'))) – For each pair, replace the first string with the second

Return type:

list[str]