Rams Poster
import json, os
from datetime import datetime
JOURNAL_FILE = "journal.json"
def load_journal():
if not os.path.exists(JOURNAL_FILE):
return {"entries": []}
with open(JOURNAL_FILE, "r", encoding="utf-8") as f:
try:
return json.load(f)
except json.JSONDecodeError:
return {"entries": []}
def save_journal(data):
with open(JOURNAL_FILE, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2)
def add_entry():
note = input("🖊️ Your note: ").strip()
if not note:
print("❗ Nothing written, skipping.")
return
entry = {
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"),
"text": note
}
journal = load_journal()
journal["entries"].append(entry)
save_journal(journal)
print("✅ Entry saved!")
def list_entries():
journal = load_journal()
for i, e in enumerate(journal["entries"], 1):
print(f"{i}. [{e['timestamp']}] {e['text']}")
def search_entries():
term = input("🔍 Search keyword: ").lower()
journal = load_journal()
matches = [e for e in journal["entries"] if term in e["text"].lower()]
for e in matches:
print(f"[{e['timestamp']}] {e['text']}")
# ---- simple interactive loop ----
while True:
choice = input("\n[A]dd [L]ist [S]earch [Q]uit: ").strip().lower()
if choice == "a":
add_entry()
elif choice == "l":
list_entries()
elif choice == "s":
search_entries()
elif choice == "q":
print("👋 Bye!")
break
else:
print("❓ Unknown option.")
Run the script, type a to add a note, l to see everything, or s to hunt for a keyword. All data lives safely in journal.json, and you can open that file any time to back it up or migrate it.
Next steps (optional)
- Add a delete option (remove by index).
- Sort entries chronologically when listing.
- Export to a plain‑text markdown file for easy reading.
Give it a try – a few minutes of codin… Read in full →
9 ·