import csv from collections import defaultdict filename = 'orders_export_1 (8)(1).csv' total = 0 with open(filename, 'r', encoding='utf-8-sig') as f: reader = csv.DictReader(f) for row in reader: name = row.get('Lineitem name', '').upper() if 'CLUB 78' in name: price = float(row.get('Lineitem price') or 0) qty = int(row.get('Lineitem quantity') or 0) discount = float(row.get('Lineitem discount') or 0) total += (price * qty) - discount print(f"Total 'CLUB 78': {total}")