dknathalage / SIT329-Project

0 stars 3 forks source link

Create a function to return an analytical report at the end of each exercise session from CSV data #43

Open nadavfedida opened 1 year ago

nadavfedida commented 1 year ago

Once we have the CSV file working properly we need to add a function that will calculate all the times held for each position, start and end time of exercise and date

nadavfedida commented 1 year ago

The receiving end of the system will have this code which will analyse the incoming data and display it locally accordingly, then save the data to a new CSV file (per session) with a unique identifying data / time stamp. Then upon completion, a report will be generated automatically and displayed. In the future upgrades, we can arrange for this report to be sent back to the bike, and or any other new subscriber that will want to get the report.

Image

The report generating portion is as following:

def analysisReport(path, name):
    print(f"\n===== Session: {name} ======")
    address = path+name+".csv"
    df = pd.read_csv(rf'{address}')
    # new2 = (df["POSITION"].value_counts()["sitting"])
    TopTubeDuration = (df.loc[df["POSITION"] == "TopTube"].sum()["DURATION"])
    PantaniDuration = (df.loc[df["POSITION"] == "Pantani"].sum()["DURATION"])
    FroomeDuration = (df.loc[df["POSITION"] == "Froome"].sum()["DURATION"])
    ElbowsDuration = (df.loc[df["POSITION"] == "Elbows"].sum()["DURATION"])

    Total = TopTubeDuration + PantaniDuration + FroomeDuration + ElbowsDuration

    print("\n_____Totals are:______ "+
        "\nTopTube: \t %.2f"%TopTubeDuration+
        "\nPantani: \t %.2f"%PantaniDuration+
        "\nFroome: \t %.2f"%FroomeDuration+
        "\nElbows: \t %.2f"%ElbowsDuration+
        "\nTotal: \t \t %.2f"%Total)