This project is a simple book filing software that I developed when I was learning to use python, I have found it useful to keep track of the books that I have read, am currently reading, and still need to read. It is simply a nice interface for keeping or
The project file format is as follows:
BookFiler project
.idea
venv
main code
file (this will be the file were the dictionary is stored and read)
# Book Filer
import pprint
import pandas as pd
from pandas import *
def ask_user():
new_or_existing = input("new/existing(n or e)?")
if new_or_existing == "n":
books = {0: ["Title", "Author", "Genre", "Pages", "Status"]}
books = add_books(books)
elif new_or_existing == "e":
xls = ExcelFile(r'C:\Users\james\PycharmProjects\BookFiler\file.xlsx')
books = xls.parse(xls.sheet_names[0])
add_view = input("add/view/remove (a, v, or r)?")
if add_view == "a":
books = add_books(books)
elif add_view == "v":
a = []
elif add_view == "r":
books = remove_books(books)
else:
raise ValueError("invalid answer, start again")
else:
raise ValueError("invalid answer, start again")
return books
def add_books(books):
how_many = int(input("How many do you want to add?"))
pos = int(len(books.keys()))
for i in range(how_many):
print(pos)
title, author, genre, pages, status = input("Title,Author,Genre,Pages,Status:").split(",")
books[pos] = [title, author, genre, pages, status]
pos = pos + 1
return books
def remove_books(books):
# books.pop("2")
pprint.pprint(books)
which_book = int(input("what book would you like to remove?"))
books[which_book] = ["0", "0", "0", "0", "0"]
return books
def export(books):
col = [0]
for i in range(len(books.keys())-1):
col.append(i+1)
df = pd.DataFrame(books, columns=col)
export_file_path = r'C:\Users\james\PycharmProjects\BookFiler\file.xlsx'
df.to_excel(export_file_path, index=False, header=True)
# main code
books = ask_user()
pprint.pprint(books)
export(books)
Below you can see some sample inputs, such as initializing and adding new entries. Entries can also be removed or the file can be simply viewed.