Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

README (6).md

📔 Personal Journal Manager

A simple, menu-driven Python File Handling project that lets you write, view, search, and delete personal journal entries — all stored safely in a plain text file called journal.txt.


📝 Project Description

Personal Journal Manager is a beginner/student-level Python console application built to demonstrate File Handling concepts in Python. It allows a user to maintain a personal diary/journal directly from the terminal. Every entry is automatically time-stamped and saved to a text file, so the journal persists even after the program closes.

The project is built using Object-Oriented Programming (OOP) with a single class, JournalManager, which contains all the core logic for adding, viewing, searching, and deleting journal entries.


🎯 Objective

The main objective of this project is to:

  • Practice real-world file handling in Python (open(), read/write/append modes).
  • Understand and apply exception handling for safe file operations.
  • Build a small, functional menu-driven console application.
  • Apply class and object concepts in a practical project.
  • Learn how to work with the datetime module to timestamp data.

✨ Features

  • ✅ Add new journal entries with automatic date & time stamps
  • ✅ Prevents saving empty entries
  • ✅ Automatically creates journal.txt if it doesn't exist
  • ✅ View all saved journal entries at once
  • ✅ Search entries using a keyword or date (case-insensitive)
  • ✅ Delete all journal entries with a confirmation prompt
  • ✅ Learn about file handling modes (r, w, a, x) directly from the menu
  • ✅ Safe error handling for missing files, permission issues, and more
  • ✅ Simple, clean, menu-driven interface that runs in a loop until exit

🛠️ Technologies Used

Technology Purpose
Python 3 Core programming language
os module Checking file existence, deleting files
datetime module Recording the current date and time
Text File (.txt) Storing journal entries permanently

🐍 Python Concepts Used

  • Classes and Objects (JournalManager)
  • Functions/Methods inside a class
  • try-except-else style exception handling
  • String methods (.strip(), .lower(), .split())
  • f-strings for formatted text
  • while True loop for a continuous menu
  • Conditional statements (if, elif, else)
  • User input handling with input()

📂 File Handling Concepts

This project is centered around Python's file handling capabilities, including:

  • Opening files using with open(...) (which automatically closes the file safely)
  • Checking whether a file exists using os.path.exists()
  • Writing data to a file
  • Appending data to an existing file
  • Reading data from a file
  • Deleting a file using os.remove()
  • Handling errors that can occur during file operations

⚙️ How the Program Works

  1. When the program starts, it displays a welcome message and a main menu.
  2. The user selects an option (1–6) by typing a number.
  3. Based on the choice, the corresponding method inside the JournalManager class is called.
  4. The program keeps looping and showing the menu until the user chooses to Exit.
  5. All journal entries are saved in a text file named journal.txt, located in the same folder as the program.

📋 Menu Options

1️⃣ Add a New Entry

  • Prompts the user to type a journal entry.
  • If the entry is empty (or just spaces), it shows an error and does not save it.
  • Records the current date and time using datetime.datetime.now().
  • If journal.txt does not exist, it is created automatically.
  • If it already exists, the new entry is appended at the end (old entries are kept safe).

2️⃣ View All Entries

  • Opens journal.txt in read mode and displays all saved entries.
  • If the file is empty, it tells the user that no entries were found.
  • If the file does not exist yet, it asks the user to add an entry first.

3️⃣ Search for an Entry

  • Asks the user to enter a keyword or a date to search for.
  • Splits the journal into individual entries and checks each one.
  • The search is case-insensitive, so "Exam" and "exam" are treated the same.
  • Displays all matching entries, or a message if nothing is found.

4️⃣ Delete All Entries

  • Asks the user to confirm with yes or no before deleting anything.
  • If the user types yes, the entire journal.txt file is deleted.
  • If the user types no, the delete operation is cancelled.
  • Any other input shows a message asking for a valid yes/no response.

5️⃣ File Handling Modes

Displays a short explanation of the file modes used in the project:

Mode Meaning
r Read the contents of a file
w Write to a file, replacing old contents
a Add (append) new content at the end
x Create a new file (fails if it already exists)

6️⃣ Exit

  • Displays a goodbye message and safely ends the program.

🚨 Exception Handling

This project handles several possible errors that can occur while working with files, so the program does not crash unexpectedly.

Exception When It Happens How It's Handled
FileNotFoundError Trying to view or search entries when journal.txt doesn't exist Shows a friendly message asking the user to add an entry first
PermissionError The program doesn't have permission to read/write/delete the file Shows an error message instead of crashing
FileExistsError Trying to create journal.txt with mode "x" when it already exists Automatically switches to append mode ("a") instead
OSError Any other general file-related error (e.g., during save or delete) Displays the error message returned by the system

Why Exception Handling Matters Here

File handling operations depend on things outside the program's control — like whether a file exists, whether the user has permission to access it, or whether the disk is available. Without proper exception handling, a single missing file or permission issue could crash the whole program. By using try-except blocks, Personal Journal Manager stays stable and gives the user clear, helpful messages instead of confusing error screens.


🗂️ Project Structure

Personal-Journal-Manager/
│
├── PR.6 FILE OPERATOR.py
├── journal.txt
└── README.md

Note: journal.txt is not included by default. It is created automatically the first time you add a journal entry (Option 1 in the menu).


▶️ How to Run the Project

Requirements

  • Python 3 installed on your computer

Steps

  1. Download or clone this project folder.
  2. Open a terminal (Command Prompt / PowerShell / Terminal) in the project folder.
  3. Run the program using:
python "PR.6 FILE OPERATOR.py"
  1. Follow the on-screen menu to add, view, search, or delete journal entries.

💻 Sample Output

The following is the actual console output produced by running the program.

Welcome Screen & Main Menu

========================================
 WELCOME TO PERSONAL JOURNAL MANAGER 
========================================

Please select an option:
1. Add a New Entry
2. View All Entries
3. Search for an Entry
4. Delete All Entries
5. File Handling Modes
6. Exit

Enter your choice: 1

Adding an Entry

Enter your journal entry: Today was a productive day. I learned about file handeling in Python.

Entry added successfully!

Viewing Entries

Please select an option:
1. Add a New Entry
2. View All Entries
3. Search for an Entry
4. Delete All Entries
5. File Handling Modes
6. Exit

Enter your choice: 2

Your Journal Entries:
----------------------------------------
[2026-08-16 05:08:58.744609]
Today was a productive day. I learned about file handeling in Python.

Searching for an Entry

Please select an option:
1. Add a New Entry
2. View All Entries
3. Search for an Entry
4. Delete All Entries
5. File Handling Modes
6. Exit

Enter your choice: 3

Enter a keyword or date to search: productive

Matching Entries:
----------------------------------------
[2026-08-16 05:08:58.744609]
Today was a productive day. I learned about file handeling in Python.

Deleting All Entries

Please select an option:
1. Add a New Entry
2. View All Entries
3. Search for an Entry
4. Delete All Entries
5. File Handling Modes
6. Exit

Enter your choice: 4

Are you sure you want to delete all entries? (yes/no): yes

All journal entries have been deleted.

File Handling Modes

Please select an option:
1. Add a New Entry
2. View All Entries
3. Search for an Entry
4. Delete All Entries
5. File Handling Modes
6. Exit

Enter your choice: 5

File Handling Modes:
----------------------------------------
r  - Read the contents of a file
w  - Write to a file and replace old contents
a  - Add new content at the end of a file
x  - Create a new file
----------------------------------------

Exiting the Program

Please select an option:
1. Add a New Entry
2. View All Entries
3. Search for an Entry
4. Delete All Entries
5. File Handling Modes
6. Exit

Enter your choice: 6

Thank you for using Personal Journal Manager.
Goodbye!

📖 Example Journal Entry

This is how a real entry looks inside journal.txt, based on the sample run above:

[2026-08-16 05:08:58.744609]
Today was a productive day. I learned about file handeling in Python.

Each entry starts with the date and time in square brackets, followed by the journal text, and ends with a blank line separating it from the next entry.


👍 Advantages

  • Lightweight — no external libraries or internet connection required.
  • Entries are saved permanently in a simple text file.
  • Easy to read and understand for beginners.
  • Demonstrates practical, real-world use of file handling and exception handling.
  • Simple menu makes it easy for anyone to use, even without programming knowledge.

⚠️ Limitations

  • All entries are stored in a single plain text file (journal.txt), with no encryption or password protection.
  • There is no way to edit or delete a single specific entry — only "Delete All" is available.
  • The search feature only checks for exact keyword/date matches within the text.
  • No graphical interface — the program runs only in the terminal/console.
  • Only one user can use the journal file at a time (no multi-user support).

🚀 Future Improvements

  • Add an option to edit or delete a single journal entry.
  • Add the ability to filter entries by a specific date.
  • Store entries in a more structured format like JSON or CSV.
  • Add basic password protection for the journal.
  • Add word count or entry statistics.
  • Allow exporting entries to a formatted report.

📚 Learning Outcomes

By completing this project, a student will learn:

  • How to read from and write to files in Python.
  • How to use with open() for safe file handling.
  • How to work with the datetime module to record timestamps.
  • How to structure a program using classes and objects.
  • How to write clean, user-friendly try-except blocks.
  • How to build a simple, functional, menu-driven console application.

✅ Conclusion

Personal Journal Manager is a simple yet practical Python project that shows how file handling, exception handling, and object-oriented programming can come together to build a useful console application. It is a great example for students who want to understand how real-world programs read, write, and manage data using text files — all without needing a database or external libraries.


Made with ❤️ using Python.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages