Skip to content

Instantly share code, notes, and snippets.

@ckocyigit
Created February 12, 2023 11:40
Show Gist options
  • Select an option

  • Save ckocyigit/967beab50364edc4be88df9a7d876820 to your computer and use it in GitHub Desktop.

Select an option

Save ckocyigit/967beab50364edc4be88df9a7d876820 to your computer and use it in GitHub Desktop.
AZAD's Python file to sum up total amount for amazon orders
import glob, csv
sum: float = 0
orders: int = 0
for file in glob.glob("*.csv"):
with open(file, 'r') as input:
csvInput = csv.DictReader(input)
for row in csvInput:
if 'SUBTOTAL' in row['total']:
continue
price = row['total']
price = price.replace('€','')
if len(price) >= 8:
price = price.replace('.','')
price = float(price.replace(',','.'))
else:
price = float(price.replace(',','.'))
sum += price
orders = orders +1
#print(price)
print(f'Du hast für {orders} Bestellung {sum}€ ausgegeben')
print(f'Durchnittlich macht das {sum/orders}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment