0% found this document useful (0 votes)
80 views

CS Project CSV

This document contains a project on library management. It includes program codes for managing books and members, as well as issuing and returning books. The codes use CSV files to store book and member records and allow adding, deleting, modifying and displaying these records. Functions are defined to manage the menu, book operations, member operations and book issue/return processes.

Uploaded by

Samir Parmar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

CS Project CSV

This document contains a project on library management. It includes program codes for managing books and members, as well as issuing and returning books. The codes use CSV files to store book and member records and allow adding, deleting, modifying and displaying these records. Functions are defined to manage the menu, book operations, member operations and book issue/return processes.

Uploaded by

Samir Parmar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Computer Science

PROJECT
ON
LIBRARY
MANAGEMENT

NAME:
CLASS:
ROLL NO. :
CERTIFICATE
This is to certify that ____________ of class ______,
_______________________ School, has successfully
completed her Investigatory Project as prescribed by CBSE in
the year ____________.

Date :

Roll No. :

Signature of Subject Signature of External


Teacher Examiner

__________________ __________________
ACKNOWLEDGEMENT

It would be my utmost pleasure to thank my


Computer Science teacher ____________ for giving
me this knowledgeable topic "LIBRARY
MANAGEMENT" and supporting me during the
course of this project. I would also like to thank my
parents and God for encouraging me and giving me
strength to complete this project on time.
Secondly, I also like to thank my partner for being
co-operative and pally with me throughout the
process and for helping me to make this a full proof
success.
PROGRAM CODE
BOOK.py

import csv

book=[

["1001","Twilight","Meyer, Stephenie","550","N"],

["1002","Lost Symbol,The","Brown, Dan","450","N"],

["1003","One Day","Nicholls, David","345","N"],

["2001","Life of Pi","Martel, Yann","420","N"],

["2002","Small Island","Levy, Andrea","370","N"],

["2003","Brick Lane","Ali, Monica","280","N"]]

with open('book.csv','w',newline='') as afile:

filewriter = csv.writer(afile,delimiter=',',lineterminator='\n')

filewriter.writerows(book)

with open('book.csv', 'r') as file:

reader = csv.reader(file)

for row in reader:

print(row)
MEMBER.py

import csv

member=[

["A001","AMIT","","Y"],

["B002","MEENA","","N"],

["C003","KANIKA","","N"],

["D001","CHARU","","N"],

["E002","MAHESH","","N"],

["F003","DIMPLE","","N"]]

with open('member.csv','w',newline='') as mfile:

filewriter = csv.writer(mfile,delimiter=',',lineterminator='\n')

filewriter.writerows(member)

with open('member.csv', 'r') as file:

reader = csv.reader(file)

for row in reader:

print(row)
LIBRARY.py

import csv

def DispMenu():

print("\n\n\n\t\t############ LIBRARY MANAGEMENT ###############")

print("\n\t\t\t 1. BOOK MANAGEMENT ")

print("\n\t\t\t 2. MEMBER MANAGEMENT ")

print("\n\t\t\t 3. ISSUE BOOK")

print("\n\t\t\t 4. RETURN BOOK")

print("\n\t\t\t 5. EXIT ")

print("\t\t#####################################################")

def BookMenu():

print("\n\n\n\t\t############ BOOK MANAGEMENT ###############")

print("\n\t\t\t 1. ADD BOOK ")

print("\n\t\t\t 2. DELETE BOOK ")

print("\n\t\t\t 3. MODIFY BOOK")

print("\n\t\t\t 4. DISPLAY BOOKS")

print("\n\t\t\t 5. EXIT ")


print("\t\t##################################################")

def MemberMenu():

print("\n\n\n\t\t############ MEMBER MANAGEMENT ###############")

print("\n\t\t\t 1. ADD MEMBER ")

print("\n\t\t\t 2. DELETE MEMBER ")

print("\n\t\t\t 3. MODIFY MEMBER")

print("\n\t\t\t 4. DISPLAY MEMBERS")

print("\n\t\t\t 5. EXIT ")

print("\t\t##################################################")

def bookadd():

bookrec=[]

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()
print("Enter the following information")

bno=input("Enter the book number:")

bname=input("Enter book name:")

bauthor=input("Enter author name:")

bprice=input("Enter book price:")

brec1=[bno,bname,bauthor,bprice]

bookrec.append(brec1)

print("book added")

with open('book.csv', 'w',newline='') as file:

writer = csv.writer(file)

writer.writerows(bookrec)

bookrec=[]

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()

print(bookrec)
def bookdelete():

bookrec=[]

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()

bno=input("Enter book Number to be deleted")

flag=0

for brec in bookrec:

if brec[0]==bno:

print("Book Details:")

print(brec)

bookrec.remove(brec)

flag=1

break

if flag==1:

print("Book has been deleted")

with open('book.csv','w',newline='') as bcsv:


bwriter = csv.writer(bcsv,delimiter=',',lineterminator='\n')

bwriter.writerows(bookrec)

else:

print("Book not found")

bookrec=[]

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()

print(bookrec)

def bookmodify():

bookrec=[]

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()
bno=input("Enter book Number to be modified")

flag=0

b1=0

for brec in bookrec:

if brec[0]==bno:

print("Book Details:")

print(brec)

print("Enter the following information")

bname=input("Enter book name:")

bauthor=input("Enter author name:")

bprice=input("Enter book price:")

br=[bno,bname,bauthor,bprice]

bookrec[b1]=br

flag=1

break

b1=b1+1

if flag==1:

print("Book has been modified")

with open('book.csv','w',newline='') as bcsv:

bwriter = csv.writer(bcsv,delimiter=',',lineterminator='\n')
bwriter.writerows(bookrec)

else:

print("Book not found")

bookrec=[]

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()

print(bookrec)

def bookdisp():

bookrec=[]

file=open('book.csv', 'r')

book1 = csv.reader(file)

print("\n\n\n########################## BOOK DETAILS #############################")

print("%10s"%"BOOK NO.","%20s"%"TITLE","%20s"%"AUTHOR","%15s"%"PRICE")

for row in book1:


print("%10s"%row[0],"%20s"%row[1],"%20s"%row[2],"%15s"%row[3])

print("\n########################## BOOK DETAILS #############################")

K=input("\n\nPress any key to continue")

file.close()

def memberadd():

memberrec=[]

file=open('member.csv', 'r')

member1 = csv.reader(file)

for mrec in member1:

memberrec.append(mrec)

file.close()

print("Enter the following information")

mno=input("Enter the member number:")

mname=input("Enter member name:")

bno=" "

status="N"

mrec1=[mno,mname,bno,status]
memberrec.append(mrec1)

print("book added")

with open('member.csv', 'w',newline='') as file:

writer = csv.writer(file)

writer.writerows(memberrec)

memberrec=[]

file=open('member.csv', 'r')

member1 = csv.reader(file)

for mrec in book1:

memberrec.append(mrec)

file.close()

print(memberrec)

def memberdelete():

memberrec=[]

file=open('member.csv', 'r')

member1 = csv.reader(file)

for mrec in member1:

memberrec.append(mrec)
file.close()

mno=input("Enter member Number to be deleted")

flag=0

for mrec in memberrec:

if mrec[0]==mno:

print("Member Details:")

print(mrec)

memberrec.remove(mrec)

flag=1

break

if flag==1:

print("Member has been deleted")

with open('member.csv','w',newline='') as mcsv:

bwriter = csv.writer(mcsv,delimiter=',',lineterminator='\n')

bwriter.writerows(memberrec)

else:

print("Book not found")

memberrec=[]
file=open('member.csv', 'r')

member1 = csv.reader(file)

for mrec in member1:

bookrec.append(mrec)

file.close()

print(memberrec)

def membermodify():

memberrec=[]

file=open('member.csv', 'r')

member1 = csv.reader(file)

for mrec in member1:

memberrec.append(mrec)

file.close()

mno=input("Enter member number to be modified")

flag=0

m1=0

for mrec in memberrec:

if mrec[0]==mno:

print("Member Details:")
print(mrec)

print("Enter the following information")

mname=input("Enter member name:")

bno=mrec[2]

status=mrec[3]

mr=[mno,mname,bno,status]

memberrec[b1]=mr

flag=1

break

m1=m1+1

if flag==1:

print("Meember has been modified")

with open('member.csv','w',newline='') as mcsv:

bwriter = csv.writer(mcsv,delimiter=',',lineterminator='\n')

bwriter.writerows(memberrec)

else:

print("Member not found")

memberrec=[]

file=open('member.csv', 'r')
member1 = csv.reader(file)

for mrec in member1:

memberrec.append(mrec)

file.close()

print(memberrec)

def memberdisp():

bookrec=[]

file=open('member.csv', 'r')

member1 = csv.reader(file)

print("\n\n\n########################## MEMBER DETAILS


#############################")

print("%10s"%"MEMBER NO.","%15s"%"NAME","%20s"%"BOOK TITLE","%15s"%"STATUS")

for row in member1:

print("%10s"%row[0],"%15s"%row[1],"%20s"%row[2],"%15s"%row[3])

print("\n########################## MEMBER DETAILS #############################")

K=input("\n\nPress any key to continue")

file.close()
def IssueBook():

bookrec=[]

memberrec=[]

file=open('member.csv', 'r')

member1 = csv.reader(file)

for mrec in member1:

memberrec.append(mrec)

file.close()

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()

mno=input("Enter Member Number")

flag=0
mr=0

for mrec in memberrec:

if mrec[0]==mno:

print("Member Details:")

print(memberrec[mr])

if mrec[3]== "N":

bno=input("Enter Book Number")

b1=0

for brec in bookrec:

if brec[0]== bno:

flag=1

if brec[4]=="N":

print("Book Details:")

print(bookrec[b1])

bookrec[b1][4]="Y"

memberrec[mr][2]=bno

memberrec[mr][3]="Y"

print("Book Successfully Issued")

print("Return the book within 10 days of issue date")

print(brec)

print(mrec)
break

else:

print("Book already issued")

b1=b1+1

if (flag==0):

print("Book already issued")

else:

print("Return the previous book")

mr=mr+1

with open('book.csv', 'w',newline='') as file:

writer = csv.writer(file)

writer.writerows(bookrec)

with open('member.csv', 'w',newline='') as file:

writer = csv.writer(file)

writer.writerows(memberrec)

def ReturnBook():

bookrec=[]

memberrec=[]
file=open('member.csv', 'r')

member1 = csv.reader(file)

for mrec in member1:

memberrec.append(mrec)

file.close()

print(memberrec)

file=open('book.csv', 'r')

book1 = csv.reader(file)

for brec in book1:

bookrec.append(brec)

file.close()

print(bookrec)

mno=input("Enter Member Number")

flag=0

m1=0

for mrec in memberrec:

if mrec[0]==mno:

print("Member Details:")

print(mrec)
b1=0

for brec in bookrec:

if mrec[2]== brec[0]:

print("Book details:")

print(brec)

flag=1

bookrec[b1][4]="N"

memberrec[m1][2]=" "

memberrec[m1][3]="N"

days=int(input("Book returned in no. of days: "))

fine=0

if (days>10):

fine=(days-10)*2

print("Deposit the fine amount:",fine)

print("Book Successfully Returned")

break

b1=b1+1

if (flag==0):

print("Book not found")

m1=m1+1

print(bookrec)
print(memberrec)

with open('book.csv', 'w',newline='') as file:

writer = csv.writer(file)

writer.writerows(bookrec)

with open('member.csv', 'w',newline='') as file:

writer = csv.writer(file)

writer.writerows(memberrec)

choice=0

while choice!=5:

DispMenu()

choice = int(input('\t\t\t ENTER YOUR CHOICE :'))

if choice==1:

ch=0

while ch!=5:

BookMenu()

ch = int(input('\t\t\t ENTER YOUR CHOICE :'))

if ch==1:
bookadd()

elif ch==2:

bookdelete()

elif ch==3:

bookmodify()

elif ch==4:

bookdisp()

elif ch==5:

break

else:

print('\n\t\t\t == INVALID CHOICE == ')

elif choice==2:

ch=0

while ch!=5:

MemberMenu()

ch = int(input('\t\t\t ENTER YOUR CHOICE :'))


if ch==1:

memberadd()

elif ch==2:

memberdelete()

elif ch==3:

membermodify()

elif ch==4:

memberdisp()

elif ch==5:

break

else:

print('\n\t\t\t == INVALID CHOICE == ')

elif choice==3:

IssueBook()

elif choice==4:
ReturnBook()

elif choice==5:

break

else:

print('\n\t\t\t == INVALID CHOICE == ')


OUTPUT SCREENSHOTS

You might also like