0% found this document useful (0 votes)
4 views2 pages

Library Management Project Python-4

The document describes a Library Management System project suitable for Class 12 Information Practices, implemented in Python using Pandas. Key features include adding, viewing, issuing, and returning books, with data stored in a CSV file. The provided Python code includes functions for each feature and a menu for user interaction.

Uploaded by

nr9017111
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Library Management Project Python-4

The document describes a Library Management System project suitable for Class 12 Information Practices, implemented in Python using Pandas. Key features include adding, viewing, issuing, and returning books, with data stored in a CSV file. The provided Python code includes functions for each feature and a menu for user interaction.

Uploaded by

nr9017111
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Library Management System Project (Python)

This project is suitable for Class 12 Information Practices. It uses Python and Pandas to manage books and
members.

Features: 1. Add new books 2. View all books 3. Issue books 4. Return books 5. Store data using CSV and Pandas
Below is the full Python code.

import pandas as pd

# Create CSV if not exists


def create_file():
try:
pd.read_csv("[Link]")
except:
df = [Link](columns=["BookID", "Title", "Author", "Status"])
df.to_csv("[Link]", index=False)

def add_book():
df = pd.read_csv("[Link]")
bid = input("Enter Book ID: ")
title = input("Enter Book Title: ")
author = input("Enter Author Name: ")
status = "Available"
[Link][len(df)] = [bid, title, author, status]
df.to_csv("[Link]", index=False)
print("Book Added Successfully!")

def view_books():
df = pd.read_csv("[Link]")
print(df)

def issue_book():
df = pd.read_csv("[Link]")
bid = input("Enter Book ID to Issue: ")
if bid in df["BookID"].values:
[Link][df["BookID"] == bid, "Status"] = "Issued"
df.to_csv("[Link]", index=False)
print("Book Issued!")
else:
print("Book Not Found!")

def return_book():
df = pd.read_csv("[Link]")
bid = input("Enter Book ID to Return: ")
if bid in df["BookID"].values:
[Link][df["BookID"] == bid, "Status"] = "Available"
df.to_csv("[Link]", index=False)
print("Book Returned!")
else:
print("Book Not Found!")

def menu():
create_file()
while True:
print("\n--- Library Management System ---")
print("1. Add Book")
print("2. View Books")
print("3. Issue Book")
print("4. Return Book")
print("5. Exit")
ch = input("Enter your choice: ")

if ch == "1":
add_book()
elif ch == "2":
view_books()
elif ch == "3":
issue_book()
elif ch == "4":
return_book()
elif ch == "5":
print("Thank You!")
break
else:
print("Invalid Choice!")

menu()

You might also like