The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a gratitude journal logger

Creating a gratitude journal logger can be a great project, whether for personal use or as a simple app to track daily gratitude entries. Below is a complete example of a basic gratitude journal logger implemented in Python. This program will:

  • Allow users to add daily gratitude entries.

  • Save entries to a local file.

  • Display previous entries.

  • Optionally, let users view entries by date.


python
import os from datetime import datetime FILE_NAME = "gratitude_journal.txt" def load_entries(): if not os.path.exists(FILE_NAME): return [] with open(FILE_NAME, "r", encoding="utf-8") as file: entries = file.readlines() return [entry.strip() for entry in entries] def save_entry(entry): with open(FILE_NAME, "a", encoding="utf-8") as file: file.write(entry + "n") def add_entry(): today = datetime.now().strftime("%Y-%m-%d") print(f"nAdding entry for {today}:") gratitude = input("What are you grateful for today? ") entry = f"{today} | {gratitude}" save_entry(entry) print("Entry saved successfully!n") def view_entries(): entries = load_entries() if not entries: print("nNo entries found.n") return print("nGratitude Journal Entries:n") for entry in entries: print(f"- {entry}") print() def main(): while True: print("Gratitude Journal Logger") print("1. Add a new gratitude entry") print("2. View all entries") print("3. Exit") choice = input("Choose an option (1/2/3): ").strip() if choice == "1": add_entry() elif choice == "2": view_entries() elif choice == "3": print("Goodbye! Keep practicing gratitude.") break else: print("Invalid choice, please select 1, 2, or 3.n") if __name__ == "__main__": main()

This is a simple console-based gratitude journal logger. You can run it on your local machine and it will save the entries into a text file (gratitude_journal.txt) in the same directory.

If you want it to be more advanced — like adding timestamps, searching entries, or exporting to CSV — let me know!

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About