Skip to content

Commit

Permalink
Merge pull request #2 from hic-infra/csv-header-accountname
Browse files Browse the repository at this point in the history
CSV header: Expect `START,END,ACCOUNTNAME,Proj$,COST`
  • Loading branch information
manics authored Jul 4, 2024
2 parents caff3bc + 7aca86e commit 313e687
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions aws_project_costs/project_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
)
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion example/2024-01-01_2024-02-01.csv
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 313e687

Please sign in to comment.