/
susub
/
report
Обзор
Документация
Войти
/
susub
/
report
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
modules/data/output.py
48 строк
2 KB
Александр Куклин
Add function descriptions
25 фев 2026, 17:12
25 фев 2026, 17:12
5cd3727
Код
Авторство
О чём код?
import pandas as pd import os from modules.massage.massager import print_info def write_to_excel(params: dict, sheets: dict) -> None: ''' Функция записывает данные в excel файл :param params: словарь с параметрами :param sheets: словарь с DataFrame :return: None ''' params['config']['report']['path'] = editing_file_name(params=params) path = params['path'] + os.sep + params['config']['report']['path'] n = 0 for description, value in sheets.items(): if n == 0: with pd.ExcelWriter(path, mode="w", engine="openpyxl") as writer: value.to_excel(writer, sheet_name=description, index=False) n = n + 1 else: with pd.ExcelWriter(path, mode="a", engine="openpyxl", if_sheet_exists="replace") as writer: value.to_excel(writer, sheet_name=description, index=False) print_info(message_code='write to excel', logs=params['log'], params_message=path) def editing_file_name(params: dict) -> str: """ Функция редактирования имени файла :param params: словарь с параметрами :return: путь с новым именем файла """ if params['date']: path = f' {params['date']}.'.join( params['config']['report']['path'].split('.')) return path