""" This module is used to manage the output files of the program. """ def format_data(data:dict, separator:str, selected_columns:list = None) -> str: """ Format the data to be saved in the output file. :param data: Data to be formatted :param selected_columns: Columns to be saved :param separator: Separator of the columns :return: Formatted data """ output = '' if selected_columns is None: selected_columns = list(data.keys()) for column_name in selected_columns: output += column_name + separator output += '\n' for i in range(len(data[selected_columns[0]])): for column in selected_columns: output += str(data[column][i]).ljust(len(column)) + separator output += '\n' return output def save_output_file(output_file:str, content:str): """ Save the output file. :param output_file: Path to the output file :param content: Content of the output file """ with open(output_file, 'w') as f: f.write(content)