File Handler Utility
A simple Python program to **read, append, and manage text files** through an interactive command-line interface. This tool allows users to view file contents, add new data, and perform repeated operations easily.
Features
* Read files: Display the contents of any text file.
* Append to files: Add new data to an existing file without overwriting.
* Interactive prompts: User-friendly prompts guide the user through actions.
* Looped operations: Perform multiple actions in a single run until exit.
* Error handling: Gracefully handles missing files and invalid inputs.
Installation
1. Make sure you have **Python 3.x** installed.
2. Clone or download the repository.
3. Navigate to the folder containing the program.
git clone <repository-url>
cd <repository-folder>Usage
- Run the Python program:
python file_handler.py
-
Follow the interactive prompts:
- Enter the file path. Example:
C:/Users/Username/Documents/myfile.txt - Choose whether to append new data (
yesorno) - Choose whether to read the file contents (
yesorno) - If appending, enter the text you want to add
- Decide if you want to perform another action (
yesorno)
- Enter the file path. Example:
Example
Enter the file path: sample.txt
Do you want to append?: yes
Do you want to read?: yes
Enter the data to append: Hello World!
File content:
Existing file content...
Hello World!
Want to perform another action? no
PROGRAM WILL CLOSE IN 3...2...1...
Code Structure
* `read_file(filepath)`: Reads and prints file content.
* `update_file(filepath, table_data)`: Appends data to the file.
* `conditionals()`: Handles user input and decides whether to read, append, or exit.
* Loop ensures repeated operations until the user chooses to exit.
Contributing
Contributions are welcome. Please open a pull request or submit issues for bug reports or feature suggestions.