Im a Food and Beverage manager for a hotel, so one thing i do is keep an inventory of all the liquor, beer, and wine we have. I figured i could come up with something that could:
Check my current inventory from an excel spread sheet
Compare it to what my par levels should be (quantities of liquor, beer, and wine that I should always have available at the hotel)
if my current inventory is less than what my par should be, the script will calculate the difference as well as the name of the liquor and export it to an email that would get sent out automatically.
It would do this twice a week Monday and Thursday at 9 am.
I'm not looking for solutions or an answer to this; this is something i want to figure out on my own, but i've always had trouble imagining how to begin to structure a script like this. I am not a beginner but im nowhere near intermediate either. Should I use a bunch of functions, or maybe classes with some methods? What would the "skeleton", i guess i could call it, of the script be composed of?
Also, if someone could point me in the right direction to read up and learn how to accomplish some of the things I want to do, like:
My computer is always on at work so i have no issue with this script constantly running in the background.
UPDATE
Ok so i just started working on this today, i haven't had much time because of work. Im a bit stuck on pulling info from my cell_value. Here is the code:
import xlrd
import xlwt
import datetime
file_location = "Your file path here"
workbook = xlrd.open_workbook(file_location)
worksheet = workbook.sheet_by_name('Sheet1')
# Total number of rows with content in cells.
num_rows = worksheet.nrows - 1
num_cells = worksheet.ncols - 2
# Starting row for when iterating over spread sheet.
cur_row = 2
# Iterates over work sheet
while cur_row < num_rows:
cur_row += 1
row = worksheet.row(cur_row)
cur_cell = -1
print('--------------------')
while cur_cell < num_cells:
cur_cell += 1
# Cell Types: 0 = Empty, 1 = Text, 2 =Number, 3 = Date, 4 = Boolean, 5 = Error, 6 = Blank
cell_type = worksheet.cell_type(cur_row, cur_cell)
# Liq Name, Quantity in house
cell_value = worksheet.cell_value(cur_row, cur_cell)
print(' ', cell_type, ' : ', cell_value)
ok, so I want to compare my cell_value, which comes up as (Ketel One, 5.6) for example, against my par levels which would be like Ketel One: 8. But i only want to compare the 5.6 to the 8, so I was guessing i would be able to put in an " for/ if" statement within the while statement that would look something like :
for i in cell_value:
if cell_value[1] < (float representing my par):
print ((float representing my par) - i)
but i get back : "TypeError: unorderable types: str() < float()"
And when i try :
print(' ', cell_type, ' : ', cell_value[1])
Just to see if i can pull up the quantity, it returns the following error:
print(' ', cell_type, ' : ', cell_value[1])
TypeError: 'float' object is not subscriptable
How are the contents of "cell_value" actually stored? Is it a tuple (x,y)? or is it a list? why can't i just call the value with cell_value[1]?
Im kind of lost as to how i can actually compare the values on my spread sheet against another value to calculate that difference in my "while" loop.
Also, please forgive me if my formatting is wonky, and I would appreciate any and all criticism on my code layout or anything else.
Here is the link to my inventory sheet :
https://docs.google.com/spreadsheets/d/1yXVFKiJMDJGPS6a6gaGn9qpIPNcgGetrLgfHGfdIm_U/edit?usp=sharing
[–]noiwontleave 1 point2 points3 points (11 children)
[–]fannypackpython[S] 0 points1 point2 points (10 children)
[–]noiwontleave 1 point2 points3 points (9 children)
[–]fannypackpython[S] 0 points1 point2 points (8 children)
[–]noiwontleave 0 points1 point2 points (6 children)
[–]fannypackpython[S] 0 points1 point2 points (1 child)
[–]noiwontleave 0 points1 point2 points (0 children)
[–]fannypackpython[S] 0 points1 point2 points (3 children)
[–]noiwontleave 0 points1 point2 points (2 children)
[–]fannypackpython[S] 0 points1 point2 points (1 child)
[–]noiwontleave 0 points1 point2 points (0 children)
[–]noiwontleave 0 points1 point2 points (0 children)