Skip to content

Commit cc813e4

Browse files
authored
Merge pull request sumanth-0#815 from DevNexis/issue-768-journal-generator
Add Personal Journal Entry Generator - Fixes sumanth-0#768
2 parents d5c8801 + a4201cd commit cc813e4

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Personal Journal Entry Generator
2+
3+
A simple Python script that generates thoughtful daily journal prompts to help users reflect on their day and maintain a consistent journaling practice.
4+
5+
## Overview
6+
7+
This tool provides randomized writing prompts across five different categories:
8+
- **Gratitude**: Prompts focused on appreciation and positive experiences
9+
- **Reflection**: Questions that encourage self-awareness and growth
10+
- **Goals**: Prompts related to personal objectives and progress
11+
- **Creativity**: Fun and imaginative questions to spark creative thinking
12+
- **Mindfulness**: Prompts centered on emotional awareness and self-care
13+
14+
## Features
15+
16+
- 📝 Generates random daily journal prompts
17+
- 🎯 Organizes prompts by category for focused reflection
18+
- 📅 Displays current date and time with each prompt
19+
- 💾 Includes functionality to save journal entries to JSON format
20+
- 🔄 Simple command-line interface
21+
- ✨ Under 100 lines of Python code
22+
23+
## Requirements
24+
25+
- Python 3.6 or higher
26+
- No external dependencies (uses only standard library)
27+
28+
## Installation
29+
30+
1. Clone this repository or download the `journal_entry_generator.py` file
31+
2. Navigate to the directory containing the script
32+
33+
## Usage
34+
35+
### Basic Usage
36+
37+
Run the script to get a random daily prompt:
38+
39+
```bash
40+
python journal_entry_generator.py
41+
```
42+
43+
This will display:
44+
- Current date and time
45+
- A randomly selected category
46+
- A thoughtful writing prompt
47+
48+
### Example Output
49+
50+
```
51+
============================================================
52+
Journal Entry - 2025-10-12 at 08:30 PM
53+
============================================================
54+
55+
Category: Gratitude
56+
57+
Today's Prompt:
58+
What are three things you're grateful for today?
59+
60+
============================================================
61+
```
62+
63+
## Code Structure
64+
65+
- `PROMPTS`: Dictionary containing categorized journal prompts
66+
- `get_daily_prompt()`: Returns a random prompt (optionally from a specific category)
67+
- `display_prompt_with_timestamp()`: Shows prompt with formatted date/time
68+
- `save_entry()`: Saves journal entries to a JSON file (for future enhancement)
69+
70+
## Contributing
71+
72+
This project is part of the [100 Lines of Python Code](https://github.com/sumanth-0/100LinesOfPythonCode) repository. Contributions and improvements are welcome!
73+
74+
## Related Issue
75+
76+
Created for issue #768: Personal Journal Entry Generator
77+
78+
## License
79+
80+
This code is part of the 100LinesOfPythonCode project. Please refer to the main repository for licensing information.
81+
82+
## Future Enhancements
83+
84+
- Add command-line arguments to select specific categories
85+
- Implement interactive mode for writing and saving entries
86+
- Add export options (Markdown, plain text)
87+
- Include prompt history tracking to avoid repetition
88+
- Add custom prompt management
89+
90+
---
91+
92+
*Happy journaling! 📓✨*
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Personal Journal Entry Generator
4+
Generates daily writing prompts to help users reflect on their day.
5+
6+
Author: Contributing to 100LinesOfPythonCode
7+
Issue: #768
8+
"""
9+
10+
import random
11+
from datetime import datetime
12+
import json
13+
import os
14+
15+
# Collection of thoughtful journal prompts organized by category
16+
PROMPTS = {
17+
"gratitude": [
18+
"What are three things you're grateful for today?",
19+
"Who made a positive impact on your day and why?",
20+
"What simple pleasure brought you joy today?",
21+
],
22+
"reflection": [
23+
"What was the most challenging moment today and how did you handle it?",
24+
"What did you learn about yourself today?",
25+
"How did you grow or improve today?",
26+
],
27+
"goals": [
28+
"What progress did you make toward your goals today?",
29+
"What's one thing you want to accomplish tomorrow?",
30+
"What obstacle can you plan to overcome this week?",
31+
],
32+
"creativity": [
33+
"If today were a movie, what would be its title and genre?",
34+
"Describe your day using only metaphors.",
35+
"What would your future self thank you for doing today?",
36+
],
37+
"mindfulness": [
38+
"What emotions did you experience most strongly today?",
39+
"What moment today deserves to be remembered?",
40+
"How did you take care of yourself today?",
41+
]
42+
}
43+
44+
def get_daily_prompt(category=None):
45+
"""Generate a random prompt, optionally from a specific category."""
46+
if category and category in PROMPTS:
47+
return random.choice(PROMPTS[category])
48+
# If no category specified, choose from all prompts
49+
all_prompts = [prompt for prompts in PROMPTS.values() for prompt in prompts]
50+
return random.choice(all_prompts)
51+
52+
def display_prompt_with_timestamp():
53+
"""Display a prompt with the current date and time."""
54+
now = datetime.now()
55+
date_str = now.strftime("%Y-%m-%d")
56+
time_str = now.strftime("%I:%M %p")
57+
58+
print(f"\n{'='*60}")
59+
print(f"Journal Entry - {date_str} at {time_str}")
60+
print(f"{'='*60}\n")
61+
62+
# Select a random category and prompt
63+
category = random.choice(list(PROMPTS.keys()))
64+
prompt = get_daily_prompt(category)
65+
66+
print(f"Category: {category.title()}")
67+
print(f"\nToday's Prompt:\n{prompt}\n")
68+
print(f"{'='*60}\n")
69+
70+
def save_entry(prompt, entry_text, filename="journal_entries.json"):
71+
"""Save journal entry to a JSON file."""
72+
entry = {
73+
"timestamp": datetime.now().isoformat(),
74+
"prompt": prompt,
75+
"entry": entry_text
76+
}
77+
78+
# Load existing entries if file exists
79+
entries = []
80+
if os.path.exists(filename):
81+
with open(filename, 'r') as f:
82+
entries = json.load(f)
83+
84+
entries.append(entry)
85+
86+
with open(filename, 'w') as f:
87+
json.dump(entries, f, indent=2)
88+
89+
print(f"Entry saved to {filename}")
90+
91+
if __name__ == "__main__":
92+
display_prompt_with_timestamp()

0 commit comments

Comments
 (0)