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.
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.
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
datetimemodule to timestamp data.
- ✅ Add new journal entries with automatic date & time stamps
- ✅ Prevents saving empty entries
- ✅ Automatically creates
journal.txtif 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
| 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 |
- Classes and Objects (
JournalManager) - Functions/Methods inside a class
try-except-elsestyle exception handling- String methods (
.strip(),.lower(),.split()) - f-strings for formatted text
while Trueloop for a continuous menu- Conditional statements (
if,elif,else) - User input handling with
input()
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
- When the program starts, it displays a welcome message and a main menu.
- The user selects an option (1–6) by typing a number.
- Based on the choice, the corresponding method inside the
JournalManagerclass is called. - The program keeps looping and showing the menu until the user chooses to Exit.
- All journal entries are saved in a text file named
journal.txt, located in the same folder as the program.
- 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.txtdoes not exist, it is created automatically. - If it already exists, the new entry is appended at the end (old entries are kept safe).
- Opens
journal.txtin 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.
- 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.
- Asks the user to confirm with
yesornobefore deleting anything. - If the user types
yes, the entirejournal.txtfile 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.
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) |
- Displays a goodbye message and safely ends the program.
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 |
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.
Personal-Journal-Manager/
│
├── PR.6 FILE OPERATOR.py
├── journal.txt
└── README.md
Note:
journal.txtis not included by default. It is created automatically the first time you add a journal entry (Option 1 in the menu).
- Python 3 installed on your computer
- Download or clone this project folder.
- Open a terminal (Command Prompt / PowerShell / Terminal) in the project folder.
- Run the program using:
python "PR.6 FILE OPERATOR.py"- Follow the on-screen menu to add, view, search, or delete journal entries.
The following is the actual console output produced by running the program.
========================================
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
Enter your journal entry: Today was a productive day. I learned about file handeling in Python.
Entry added successfully!
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.
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.
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.
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
----------------------------------------
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!
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.
- 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.
- 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).
- 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.
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
datetimemodule to record timestamps. - How to structure a program using classes and objects.
- How to write clean, user-friendly
try-exceptblocks. - How to build a simple, functional, menu-driven console application.
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.