Skip to content

A Python-based console application for managing a personal library, including adding, removing, sorting, and filtering books.

Notifications You must be signed in to change notification settings

barsuchellos/Library-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Library Management Project 📚

Overview

This project is a simple Library Management System written in Python. It allows you to manage books using classes, objects, and JSON file storage. You can add, remove, find, count, filter, and sort books.


Features

  • Add a book with title, author, and year.
  • Remove a book by title.
  • Find a book by title.
  • Show all books in the library.
  • Count books in the library.
  • Filter books by author or year.
  • Sort books by title or year.
  • Persistent storage using JSON file (data.json).

Project Structure

/project
│
├─ main.py           # Main program
├─ library.py        # Classes for Book and Library
├─ commands.py       # Functions for user commands
├─ json_storage.py   # Functions to handle JSON storage
├─ data.json         # JSON file storing book data

How to Run

  1. Make sure you have Python 3 installed.
  2. Run the main program:
python main.py
  1. Use the following commands:
add     - add a new book
show    - show all books
find    - find a book by title
remove  - remove a book by title
count   - count books in the library
filter  - filter books by author or year
sort    - sort books by title or year
help    - show help menu
exit    - exit the program

Example Usage

Adding a book

Enter command: add
Enter title: Dune
Enter author: Frank Herbert
Enter year: 1965
Book added successfully!

Showing all books

Enter command: show
Library collection:
1984 — George Orwell (1949)
The Master and Margarita — Mikhail Bulgakov (1967)
Dune — Frank Herbert (1965)

Finding a book

Enter command: find
Enter book title: Dune
Found: Dune — Frank Herbert (1965)

Removing a book

Enter command: remove
Enter book title: Dune
Book 'Dune' has been removed.

Filtering books

Enter command: filter
Which filter you want: by author name of author(write 'author') or  year of book(write 'year')?author
Enter author name: George Orwell
Filtered books:
1984 — George Orwell (1949)

Sorting books

Enter command: sort
Which sort you want: 'title' or 'year'?year
1984 — George Orwell (1949)
The Master and Margarita — Mikhail Bulgakov (1967)

JSON Data Example (data.json)

[
    {
        "title": "1984",
        "author": "George Orwell",
        "year": 1949
    },
    {
        "title": "The Master and Margarita",
        "author": "Mikhail Bulgakov",
        "year": 1967
    },
    {
        "title": "Dune",
        "author": "Frank Herbert",
        "year": 1965
    }
]

Technical Notes

  • Uses OOP (Object-Oriented Programming) principles: classes, objects, methods.
  • Commands are handled via functions in commands.py.
  • JSON module is used for persistent storage.
  • All books remain in the list and JSON file; nothing is removed from memory unless using the remove command.
  • Proper error handling is implemented for missing books or invalid filters.

Author

Bohdan Borsuk

About

A Python-based console application for managing a personal library, including adding, removing, sorting, and filtering books.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages