utils.files.output.format_data

utils.files.output.format_data(data: dict, separator: str, selected_columns: list = None) str

Format the data to be saved in the output file.

Parameters:
  • data – Data to be formatted

  • selected_columns – Columns to be saved (in the specified order)

  • separator – Separator of the columns

Returns:

Formatted data

Example:
>>> data = {
...     'col1': [1, 2, 3],
...     'col2': [4, 5, 6],
...     'col3': [7, 8, 9]
... }
>>> format_data(data, separator=';')
'col1;col2;col3
 1   ;4   ;7
 2   ;5   ;8
 3   ;6   ;9
'