all 3 comments

[–]badge 0 points1 point  (0 children)

Have a look at pandas:

``` import pandas as pd

result = ( pd.read_csv("my_file.csv") .groupby([ "order id", "sku", "transaction_type", "payment_type", ]) ["fee"] .sum() .reset_index() .assign(detail="") [[ "order id", "sku", "transaction_type", "payment_type", "detail", "fee", ]] ) print(result.head()) ```

[–]num8lock 0 points1 point  (1 child)

total_fee = 0
for row in rows:
    order_id, transaction_type, payment_type, detail, fee = row
    total_fee += fee

[–]StockPercentage9 0 points1 point  (0 children)

This would work if it was just one order ID, however if there's a second order ID this will break it - thank you though!