A analysis/timesheets.sas => analysis/timesheets.sas +26 -0
@@ 0,0 1,26 @@
+proc import datafile="/home/u44593168/timesheets_sas.csv"
+ out=work.raw
+ dbms=csv
+ replace;
+ getnames=no;
+run;
+
+data work.clean;
+ set work.raw;
+ project = VAR1;
+ date = VAR2;
+ hours = VAR3;
+ drop VAR1 VAR2 VAR3;
+run;
+
+proc sort data=work.clean;
+ by project date;
+run;
+
+proc timeseries data=work.clean
+ out=work.final;
+ by project;
+ id date interval=day accumulate=total;
+ var hours;
+run;
+
A analysis/totals.py => analysis/totals.py +32 -0
@@ 0,0 1,32 @@
+#!/usr/bin/env python3
+
+def totals(timesheets):
+ projects = {}
+
+ for timesheet in timesheets:
+ for entry in timesheet:
+ key = entry.project
+ if entry.time_code in ("HOL", "OTU", "VAC", "OPL", ):
+ key = entry.time_code
+
+ if key not in projects.keys():
+ projects[key] = {}
+ projects[key]["name"] = entry.label
+ projects[key]["hours"] = 0
+
+ for hours in entry.data.values():
+ projects[key]["hours"] += hours
+
+ for project, data in projects.items():
+ print(f"{project:20} {data['name']:100} {data['hours']}")
+
+def total_ocps2020(timesheets):
+ total = 0
+ for timesheet in timesheets:
+ for entry in timesheet:
+ if entry.project == "20032.001.20.005":
+ for date, hours in entry.data.items():
+ total += hours
+ break
+ print(f"{total} hours spent on OCPS 2020")
+
M main.py => main.py +4 -0
@@ 10,6 10,8 @@ from parser.timesheet import parse as parse_timesheet
from exporter.long_csv import export
+from analysis.totals import totals, total_ocps2020
+
def main(filelist):
timesheets = []
@@ 26,6 28,8 @@ def main(filelist):
dest_filename = pathlib.Path("analysis/timesheets_sas.csv")
export(dest_filename, timesheets)
+ total_ocps2020(timesheets)
+
if __name__ == "__main__":
filelist = []
for filename in sys.argv[1:]: