-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdailyjournaling.py
More file actions
94 lines (80 loc) · 2.36 KB
/
dailyjournaling.py
File metadata and controls
94 lines (80 loc) · 2.36 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import csv
import random
from datetime import datetime
from pathlib import Path
# -------- CONFIG --------
DATA_FILE = Path("daily_journal_log.csv")
JOURNAL_PROMPTS = [
"What was the highlight of your day?",
"What challenged you today and how did you handle it?",
"What did you learn today?",
"What made you smile today?",
"What is something you want to improve tomorrow?",
"How did you take care of yourself today?",
"What are you proud of today?"
]
# ------------------------
def get_today():
return datetime.now().strftime("%Y-%m-%d")
def get_journal_prompt():
return random.choice(JOURNAL_PROMPTS)
def ask_gratitude():
print("\n🙏 Gratitude Time (3 things):")
gratitude = []
for i in range(1, 4):
item = input(f" {i}. ")
gratitude.append(item)
return " | ".join(gratitude)
def ask_mood():
while True:
try:
mood = int(input("\n😊 Mood today (1 = awful, 5 = great): "))
if 1 <= mood <= 5:
break
else:
print("Please enter a number between 1 and 5.")
except ValueError:
print("Please enter a number.")
note = input("Mood note (optional): ")
return mood, note
def save_entry(date, prompt, journal, gratitude, mood, mood_note):
file_exists = DATA_FILE.exists()
with open(DATA_FILE, mode="a", newline="", encoding="utf-8") as file:
writer = csv.writer(file)
if not file_exists:
writer.writerow([
"date",
"journal_prompt",
"journal_entry",
"gratitude",
"mood_score",
"mood_note"
])
writer.writerow([
date,
prompt,
journal,
gratitude,
mood,
mood_note
])
def main():
print("\n📝 Daily Journal Automation\n" + "-" * 30)
today = get_today()
prompt = get_journal_prompt()
print(f"\n📌 Journal Prompt:\n{prompt}")
journal_entry = input("\nYour response:\n")
gratitude = ask_gratitude()
mood, mood_note = ask_mood()
save_entry(
today,
prompt,
journal_entry,
gratitude,
mood,
mood_note
)
print("\n✅ Entry saved successfully!")
print(f"📂 File: {DATA_FILE.resolve()}")
if __name__ == "__main__":
main()