/
Hetvild
/
QR-Label-Bot
Обзор
Документация
Войти
/
Hetvild
/
QR-Label-Bot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/utils/read_excel.py
31 строка
1 KB
bil
init
28 янв 2026, 10:55
28 янв 2026, 10:55
d88afd0
Код
Авторство
О чём код?
import pandas as pd from loguru import logger def read_excel(file_path) -> list[dict[str, str]]: """ Функция для чтения excel файла :param file_path: :return: list[dict[str, str]] """ # Для .xls используем 'xlrd', для .xlsx - 'openpyxl' (автоматически определяется) logger.debug(type(file_path)) df = pd.read_excel(file_path) # Выводим два указанных столбца, а также, если встречаются пустые строки, то эти строки удаляются names = df[["Barcode_VIN_Combined", "Model", "Color", "VIN"]].dropna(how="all") result = [] # Обходим переменную names в цикле и извлекаем данные из 2-х столбцов for row in names.itertuples(): barcode: str = row.Barcode_VIN_Combined.strip() model: str = row.Model.strip() color: str = row.Color.strip() vin: str = row.VIN.strip() logger.info(barcode, model, color, vin) result.append({"barcode": barcode, "model": model, "color": color, "vin": vin}) return result