76 lines
2.3 KiB
Python
76 lines
2.3 KiB
Python
from clize import run
|
|
from typing import List
|
|
|
|
from core.skill import Skill
|
|
from core.routine import Routine
|
|
from core.routine_statistics import RoutineStatistics
|
|
|
|
from openpyxl import load_workbook
|
|
|
|
|
|
def read_routine_file(filename: str) -> List[Routine]:
|
|
"""
|
|
Read the excel file, interpret all the jumps found and build the series.
|
|
|
|
Args:
|
|
filename <string> path du fichier à analyser
|
|
"""
|
|
|
|
wb = load_workbook(filename)
|
|
routine_sheet = wb.active
|
|
max_col = routine_sheet.max_column
|
|
routine_list = list()
|
|
|
|
for column in range(1, max_col + 1):
|
|
current_routine = Routine()
|
|
|
|
for row in range(2, 12):
|
|
current_cell = routine_sheet.cell(row=row, column=column)
|
|
|
|
if current_cell.value is not None:
|
|
skill = Skill(current_cell.value)
|
|
if skill:
|
|
current_routine.add_skill(skill)
|
|
else:
|
|
break
|
|
|
|
routine_list.append(current_routine)
|
|
|
|
return routine_list
|
|
|
|
|
|
def run_process(xlsx_filename: str, *, mean_routine:'r'=False, heatmap:'t'=False):
|
|
"""Read a XLSX file whitch contain trampoline routines, analyse it and generate a XLSX results file with tree
|
|
sheets.
|
|
|
|
:param xlsx_filename: path to the xlsx to analyse.
|
|
:param mean_routine: compute and write mean routine in the results file.
|
|
:param heatmap: display heatmap at the end of the process.
|
|
"""
|
|
output_filename = xlsx_filename[:-5] + "_analysed.xlsx"
|
|
|
|
print("Reading XLSX file")
|
|
routine_list = read_routine_file(xlsx_filename)
|
|
print("Making statistics")
|
|
routine_stats = RoutineStatistics(routine_list)
|
|
print("Writing simple skill statistics")
|
|
routine_stats.write_skill_simple_statistics(output_filename)
|
|
print("writing detailed skill statistics")
|
|
routine_stats.write_skill_detailled_statistics(output_filename)
|
|
print("Writing combination statistics")
|
|
routine_stats.write_combination_frequency(output_filename)
|
|
|
|
if mean_routine:
|
|
print("Computing mean routine")
|
|
routine_stats.compute_routine()
|
|
print("Writing mean routine")
|
|
routine_stats.write_mean_routine(output_filename)
|
|
|
|
if heatmap:
|
|
print("Computing heatmap")
|
|
routine_stats.draw_heatmap_combination()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run(run_process)
|