From 7aca86e194eb8d3d7e2b65d9b350c15d2ec2e8a4 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 4 Jul 2024 17:47:00 +0100 Subject: [PATCH] CSV header: Expect `START,END,ACCOUNTNAME,Proj$,COST` --- aws_project_costs/project_costs.py | 6 +++--- example/2024-01-01_2024-02-01.csv | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aws_project_costs/project_costs.py b/aws_project_costs/project_costs.py index 6388fae..0f255a4 100644 --- a/aws_project_costs/project_costs.py +++ b/aws_project_costs/project_costs.py @@ -118,7 +118,7 @@ def allocate_costs( ) -> list[tuple[str, str, str, Any, str, Any]]: account_cfg = _get_account_cfg(config, accountname) - costs = df[(df["START"] == start) & (df["accountname"] == accountname)] + costs = df[(df["START"] == start) & (df["ACCOUNTNAME"] == accountname)] billing_type = account_cfg["billing-type"] costs_dict = costs.to_dict(orient="records") @@ -167,7 +167,7 @@ def analyse_costs_csv( ) -> None: df = pd.read_csv( costs_csv_filename, - dtype={"accountname": str, f"{PROJECT_TAG}$": str, "COST": float}, + dtype={"ACCOUNTNAME": str, f"{PROJECT_TAG}$": str, "COST": float}, parse_dates=["START", "END"], date_format="ISO8601", ) @@ -176,7 +176,7 @@ def analyse_costs_csv( for start in sorted(df["START"].unique()): month_costs = df[df["START"] == start] - for accountname in month_costs["accountname"].unique(): + for accountname in month_costs["ACCOUNTNAME"].unique(): # print(f"Processing {accountname} {start}") try: acc_itemised_rows = allocate_costs( diff --git a/example/2024-01-01_2024-02-01.csv b/example/2024-01-01_2024-02-01.csv index ecdb5d6..12cbf5c 100644 --- a/example/2024-01-01_2024-02-01.csv +++ b/example/2024-01-01_2024-02-01.csv @@ -1,4 +1,4 @@ -START,END,accountname,Proj$,COST +START,END,ACCOUNTNAME,Proj$,COST 2024-01-01,2024-02-01,aws-auth,Proj$,21.32342 2024-01-01,2024-02-01,aws-auth,Proj$project-001,21.24323 2024-01-01,2024-02-01,aws-auth,Proj$project-002,0.1231