From 3b3f6192f2e9a1680cf5516ca37415037d3faa48 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 29 Aug 2021 11:37:28 -0700 Subject: [PATCH] Additional work --- financials/fin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/financials/fin.py b/financials/fin.py index ed639de..e5cc044 100755 --- a/financials/fin.py +++ b/financials/fin.py @@ -88,7 +88,7 @@ def read_csv(csv_path): reader = csv.reader(f) header = next(reader) for row in reader: - rows.append(dict(zip(header, row))) + rows.append(dict((key, val) for (key, val) in zip(header, row) if val)) return rows @@ -98,7 +98,8 @@ def classify_costs(csv_path): cost = decimal.Decimal(item["lineItem/UnblendedCost"]) if not cost: continue - breakpoint() + category = f"{item['lineItem/LineItemType']} - {item['lineItem/ProductCode']} - {item['lineItem/UsageType']} - {item.get('lineItem/ResourceId', '(no resource)')}" + print(f"{category} :: ${cost:.2f}") def main(): @@ -108,7 +109,7 @@ def main(): args = parser.parse_args() year, month = map(int, args.date.split("-")) csv_path = get_csv(year, month, force_download=args.force_download) - analyze(csv_path) + classify_costs(csv_path) if __name__ == "__main__":