0% found this document useful (0 votes)
39 views6 pages

Computer

ip project

Uploaded by

akshatsai216
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)
39 views6 pages

Computer

ip project

Uploaded by

akshatsai216
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
You are on page 1/ 6

javascript\hello.

py

1 import pandas as pd
2 import matplotlib.pyplot as plt
3 from datetime import date
4
5 NATIONAL_DIGITAL_LIB­
RARY = ["bookid", "title", "author", "publisher",
"edition", "cost", "category"]
6
7 def add_book():
8 bookid = int(input("Enter book id: "))
9 title = input("Enter book title: ")
10 author = input("Enter author of the book: ")
11 publisher = input("Enter book publisher: ")
12 edition = input("Enter edition of book: ")
13 cost = int(input("Enter cost of the book: "))
14 category = input("Enter category of book: ")
15
16 bdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv")
17 n = bdf["bookid"].count()
18 bdf.loc[n] = [bookid, title, author, publisher, edition, cost,
category]
19 bdf.to_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv", index=False)
20 print("Book added successfully")
21 print(bdf)
22
23 def search_book():
24 title = input("Enter a book name: ")
25 bdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv")
26 df = bdf.loc[bdf["title"] == title]
27 if df.empty:
28 print("No book found with given code")
29 else:
30 print("Books details are :")
31 print(df)
32
33 def delete_book():
34 bookid = float(input("Enter a book id: "))
35 bdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv")
36 bdf = bdf.drop(bdf[bdf["bookid"] == bookid].index)
37 bdf.to_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv", index=False)
38 print("Book Deleted Successfully")
39 print(bdf)
40
41 def show_books():
42 bdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv")
43 print(bdf)
44
45 def add_new_member():
46 mid = int(input("Enter member id: "))
47 mname = input("Enter member name: ")
48 phoneno = int(input("Enter phone number: "))
49 number_of_books_issu­
ed = 0
50 mdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv")
51 n = mdf["mid"].count()
52 mdf.loc[n] = [mid, mname, phoneno, number_of_books_issu­
ed]
53 mdf.to_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv", index=False)
54 print("New Member added successfully")
55 print(mdf)
56
57 def search_member():
58 mname = input("Enter a member name: ")
59 mdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv")
60 df = mdf.loc[mdf["mname"] == mname]
61 if df.empty:
62 print("No member found with given name")
63 else:
64 print("Members details are :")
65 print(df)
66
67 def delete_member():
68 mid = float(input("Enter member id: "))
69 mdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv")
70 mdf = mdf.drop(mdf[mdf["mid"] == mid].index)
71 mdf.to_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv", index=False)
72 print("Member Deleted Successfully")
73 print(mdf)
74
75 def delete_member():
76 mid = float(input("Enter a member id: "))
77 mdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv")
78 mdf = mdf.drop(mdf[mdf["mid"] == mid].index)
79 mdf.to_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv", index=False)
80 print("Member Deleted Successfully")
81 print(mdf)
82
83 def show_members():
84 mdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv")
85 print(mdf)
86
87 def issue_books():
88 book_name = input("Enter book name: ")
89 bdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv")
90 bdf = bdf.loc[bdf["title"] == book_name]
91 if bdf.empty:
92 print("No Book Found in the Library")
93 else:
94 m_name = input("Enter member name: ")
95 mdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\member.csv")
96 mdf = mdf.loc[mdf["mname"] == m_name]
97 if mdf.empty:
98 print("No such Member Found")
99 else:
100 date_of_issue = int(input("Enter date of issue: "))
101 number_of_book_issue­
d = int(input("Enter number of book
issued: "))
102 bdf = pd.read_csv(r"D:\IP LIBRARY\EXEL
FILES\issuebooks.csv")
103 n = bdf["book_name"].count()
104 bdf.loc[n] = [book_name, m_name, date.today(),
number_of_book_issue­
d, ""]
105 bdf.to_csv(r"D:\IP LIBRARY\EXEL FILES\issuebooks.csv",
index=False)
106 print("Book issued successfully")
107 print(bdf)
108
109 def return_book():
110 mname = input("Enter a member name: ")
111 book_name = input("Enter book name: ")
112 idf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\issuebooks.csv")
113 idf = idf.loc[idf["book_name"] == book_name]
114 if idf.empty:
115 print("The book is not issued in records")
116 else:
117 idf = idf.loc[idf["m_name"] == mname]
118 if idf.empty:
119 print("The book is not issued to the member")
120 else:
121 print("Book can be returned")
122 ans = input("Are you sure you want to return the book: ")
123 if ans.lower() == "yes":
124 idf = pd.read_csv(r"D:\IP LIBRARY\EXEL
FILES\issuebooks.csv")
125 idf = idf.drop(idf[idf["book_name"] ==
book_name].index)
126 idf.to_csv(r"D:\IP LIBRARY\EXEL FILES\issuebooks.csv",
index=False)
127 print("Book Returned Successfully")
128 else:
129 print("Return operation cancelled")
130
131 def show_issued_books():
132 idf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\issuebooks.csv")
133 print(idf)
134
135 def delete_issued_books():
136 book_name = input("Enter a book name: ")
137 bdf = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\issuebooks.csv")
138 bdf = bdf.drop(bdf[bdf["book_name"] == book_name].index)
139 bdf.to_csv(r"D:\IP LIBRARY\EXEL FILES\issuebooks.csv",
index=False)
140 print("Deleted Issued Book Successfully")
141 print(bdf)
142
143 def show_charts():
144 print("Press 1 Books and their Cost")
145 print("Press 2 Number of Books issued by members")
146 ch = int(input("Enter your choice: "))
147 if ch == 1:
148 df = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\book.csv")
149 df = df[["title", "cost"]]
150 df.plot(kind="bar")
151 plt.xlabel("title")
152 plt.ylabel("cost")
153 plt.show()
154 elif ch == 2:
155 df = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\issuebooks.csv")
156 df = df[["number_of_book_issue­
d", "m_name"]]
157 df.plot(kind="bar", color="red")
158 plt.show()
159
160 def login():
161 uname = input("Enter Username: ")
162 pwd = input("Enter Password: ")
163 df = pd.read_csv(r"D:\IP LIBRARY\EXEL FILES\users.csv")
164 df = df.loc[df["username"] == uname]
165 if df.empty:
166 print("Invalid Username given")
167 return False
168 df = df.loc[df["password"] == pwd]
169 if df.empty:
170 print("Invalid Password")
171 return False
172 print("Username and Password matched successfully")
173 return True
174
175
176 def show_menu():
177 print("NATIONAL DIGITAL LIBRARY ASSOCIATION")
178 print("1. Add a New Book")
179 print("2. Show All Books")
180 print("3. Add New Member")
181 print("4. Search for a Member")
182 print("5. Delete Member")
183 print("6. Show All Members")
184 print("7. Login")
185 print("8. Search for a Book")
186 print("9. Delete a Book")
187 print("10. Issue a Book")
188 print("11. Return a Book")
189 print("12. Show All Issued Books")
190 print("13. Delete Issue Book")
191 print("14. To view Charts")
192 print("15. To exit")
193 choice = int(input("Enter your choice: "))
194 return choice
195
196 while True:
197 ch = show_menu()
198 if ch == 1:
199 add_book()
200 elif ch == 2:
201 show_books()
202 elif ch == 3:
203 add_new_member()
204 elif ch == 4:
205 search_member()
206 elif ch == 5:
207 delete_member()
208 elif ch == 6:
209 show_members()
210 elif ch == 7:
211 login()
212 elif ch == 8:
213 search_book()
214 elif ch == 9:
215 delete_book()
216
217

You might also like