About me

Hi! My name is Allie Burke, I’m a Senior at The College of William and Mary.

I’m a Finance Major and Data Science Minor.

Hobbies
  • running

  • knitting

  • yoga

Sample script

Book_keeping (.py)

I wrote this sample script as a way to keep up with daily inventory changes at a small used bookstore that mostly has one copy of each book. It has the user load in two excel files that contain the inventory list and the sales made that day. My script checks to see which books were purchased, and returns an excel file with the new inventory list that can be used for the next day.

#!/usr/bin/env python3
#
# Book_keeping.py
#
#
# LAST EDIT: 2020-02-09
#
# This script compares entries in inventory and sales lists.
#
##############################################################################
# REQUIRED MODULES
##############################################################################


import pandas as pd
inventory = []
booksales = []

def Book_keeping(Inventory, Daily_sales):

    #reads in the two excel files

    Inventory = pd.read_excel(Inventory)
    Today_total = pd.read_excel(Daily_sales)

    #converts the idCode columns in each sheet into integers

    for num in Inventory["idCode"]:
        int(num)
    for digit in Today_total["idCode"]:
        int(digit)

    #iterates over the idCode column and creates a list for both sheets

    for copies in Inventory["idCode"]:
        inventory.append(copies)
    for book in Today_total["idCode"]:
        booksales.append(book)

    #Calculates where the new day's inventory will appear in the excel sheet

    tail = (len(inventory)-len(booksales))

    #removes purchased books from the inventory

    for book in booksales:
        inventory.remove(book)

    #adds the new inventory to the excel sheet

    for a in inventory:
        for part in Inventory["idCode"]:

            if a == part:
                Inventory = Inventory.append(Inventory.loc[Inventory["idCode"]== a])

    #removes the earlier entries

    Inventory = Inventory.tail(tail)

    #returns the final inventory list to be used the next day

    return Inventory.to_excel("NewInventory.xlsx",sheet_name = "Inventory",engine='xlsxwriter')

Book_keeping("Inventory.xlsx","Today.xlsx")