-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoodtrack.py
More file actions
36 lines (28 loc) · 1.23 KB
/
moodtrack.py
File metadata and controls
36 lines (28 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import csv, datetime, os
FILE = "mood_log.csv"
def mood_to_emoji(m):
return {"happy":"😊","sad":"😢","neutral":"😐","angry":"😠","excited":"🤩"}.get(m,"")
def add_mood():
mood = input("Mood today? (happy/sad/neutral/angry/excited): ").lower()
with open(FILE, 'a', newline='') as f:
csv.writer(f).writerow([datetime.date.today(), mood])
print("Mood saved! 😊")
def view_history():
if not os.path.exists(FILE): return print("No mood data found.")
print("\n=== Mood History ===")
for d, m in csv.reader(open(FILE)):
print(f"{d} - {m.capitalize()} {mood_to_emoji(m)}")
def summary():
if not os.path.exists(FILE): return print("No mood data to summarize.")
moods = [m for _, m in csv.reader(open(FILE))]
print("\n=== Mood Summary ===")
for m in set(moods):
print(f"{m.capitalize()}: {moods.count(m)} days {mood_to_emoji(m)}")
while True:
print("\n==== Daily Mood Tracker ====\n1. Add Mood\n2. View History\n3. Summary\n4. Exit")
c = input("Choice (1-4): ")
if c == '1': add_mood()
elif c == '2': view_history()
elif c == '3': summary()
elif c == '4': print("Goodbye! 🌈"); break
else: print("Invalid choice.")