Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
StudyTime.csv
SudyTime_test.csv
test.py
20 changes: 16 additions & 4 deletions study_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
import matplotlib.pyplot as plt
import pandas as pd

# importing the cvs in which to record study sessions
# importing the cvs in which to record study sessions.
# The file is always saved in the same folder where
# the file study_time.py is located, wherever the
# script is runned.

# get path of where this file is located
script_dir = os.path.dirname(os.path.abspath(__file__))
data_file = os.path.join(script_dir, "StudyTime.csv")

# subjects = list of subjects to study
data_file = "StudyTime.csv"
if os.path.exists(data_file):
df = pd.read_csv(data_file)
subjects = df["Subject"].fillna("NaN").unique().tolist()
Expand Down Expand Up @@ -143,7 +150,6 @@ def show_statistics():
# Total minutes per subject
print("\nTotal minutes per subject:")
df_subj = df.groupby("Subject")["Seconds"].sum()
print(type(df_subj[0]))
print(df_subj.apply(format_time))

# Daily totals
Expand All @@ -159,8 +165,14 @@ def show_statistics():

# Overall total
total_all = df["Seconds"].sum()
print(f"\nOverall study time: {format_time(total_all)}\n")
print(f"\nOverall study time: {format_time(total_all)}")

today = pd.Timestamp.today().normalize()

# Filter for rows matching today and sum the seconds
today_seconds = df[df["Date"] == today]["Seconds"].sum()

print(f"Study time today: {format_time(today_seconds)}")

def show_plots():
"""
Expand Down