Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV header: Expect START,END,ACCOUNTNAME,Proj$,COST #2

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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