import os # 1. Загрузка заказов из файла def load_orders(filepath: str) -> list[dict]: """ Читает файл с заказами. Формат строки: user_id, item_name, quantity, price_per_item """ orders = [] with open(filepath, 'r', encoding='utf-8') as file: for line in file: line = line.strip() if not line: continue parts = line.split(',') if len(parts) != 4: continue user_id = int(parts[0].strip()) item_name = parts[1].strip() quantity = int(parts[2].strip()) price = float(parts[3].strip()) total = quantity * price orders.append({ 'user_id': user_id, 'item_name': item_name, 'quantity': quantity, 'price': price, 'total': total }) return orders