Skip to content

A mini project of python using basic concepts of python especially File handling and Exception handling. Using this mini project we can do CRUD(Create, Read, Update, Delete) operations on file smoothly.

Notifications You must be signed in to change notification settings

gitdhruv-tech/CRUD-on-File

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

That's excellent! Since your mini-project is a Python CLI utility for File and Exception Handling using the pathlib and os modules, I'll generate a tailored README file for it.

This README focuses on the purpose of the project, how to run it, and highlights the core concepts it demonstrates.


πŸ“‚ File Operations CLI Utility

πŸ’‘ About The Project

This project is a Mini-Project demonstrating fundamental Python concepts in File Handling and Exception Management. It provides a simple Command Line Interface (CLI) that allows a user to perform basic CRUD (Create, Read, Update, Delete) operations on files within the current directory.

The primary goals of this utility are to illustrate:

  • File Handling: Using Python's built-in open() function with various modes ('w', 'r', 'a').
  • Path Management: Leveraging the modern pathlib.Path module for robust file system interactions (checking existence, renaming, and reading file information).
  • Exception Handling: Implementing try...except blocks to gracefully manage common errors like FileNotFoundError, PermissionError, and invalid user input (ValueError).

Built With

  • Python 3.x
  • pathlib (Standard Library)
  • os (Standard Library)

πŸ› οΈ Getting Started

Follow these steps to get a copy of the project running on your local machine.

Prerequisites

You only need Python 3.8 or newer installed on your system.

Installation

  1. Clone the repository:
    git clone https://github.com/gitdhruv-tech/CRUD-on-File.git
  2. Navigate to the project directory:
    cd CRUD-on-File
  3. Ensure the main script is present: The file containing the code (e.g., main.py or similar) should be in this directory.

πŸƒ Usage

Run the script directly from your terminal. The application will start and present the main menu.

python main.py

Main Menu Operations

The utility provides the following functions:

Menu Option Function Demonstrates
1 Create a file Using open(..., 'w') and path existence checks.
2 Read a file Using open(..., 'r') and handling FileNotFoundError.
3 Update a file File renaming (.rename()), content overwriting ('w'), and appending ('a').
4 Delete a file Using Path.unlink() or os.remove() to delete a file.
5 Exit Terminates the program loop.

Note: All file operations are performed relative to the directory where you execute the script.


🀝 Contributing

This is a mini-project focused on fundamental concepts. However, suggestions for improving the code's robustness, adding better input validation, or using more specific exception types are welcome!

  1. Fork the Project.
  2. Create your Feature Branch (git checkout -b feature/better-validation).
  3. Commit your Changes (git commit -m 'Refactor: Improved input validation in main menu').
  4. Push to the Branch (git push origin feature/better-validation).
  5. Open a Pull Request.

βš–οΈ License

Distributed under the MIT License. See LICENSE for more information.


πŸ“§ Contact

Dhruv Maheshwari - dhruv.mahe.003@gmail.com

Project Link: https://github.com/gitdhruv-tech/CRUD-on-File

About

A mini project of python using basic concepts of python especially File handling and Exception handling. Using this mini project we can do CRUD(Create, Read, Update, Delete) operations on file smoothly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages