def main(): import pyFunctions01 masterPLU = open('Master PLU List.txt', 'r') pluNameList = masterPLU.readlines() masterPLU.close() masterPLU = [] masterName = [] masterPrice = [] masterEquivPLU = [] masterEquivQnt = [] for i in range(len(pluNameList)): masterList = pluNameList[i].split() masterPLU.append(masterList[0]) masterName.append(masterList[1:-3]) masterPrice.append(masterList[-3]) masterEquivPLU.append(masterList[-2]) masterEquivQnt.append(masterList[-1]) import time name = input("Your Name (First Last): ") date = time.strftime("%Y,%m,%d %H,%M,%S") # Create file name year = date[0:4] month = date[4:6] day = date[6:8] nameList = name.split(" ") lastName = nameList[-1] firstName = nameList[0] newFileName = date+" "+"BEGIN"+" "+lastName+" "+firstName+".txt" errorFileName = date+" "+"ERROR"+" "+lastName+" "+firstName+".txt" # Gather PLU information (plu, amt) counter1 = 0 pluList = [] quantityList = [] newList = [] while True: pluName = input("Type or scan the PLU: ") if pluName == 'END': break else: pluExists, pluIndex = checkPLU(pluName,masterPLU) if pluExists == 0: playBuzzer('Buzzer.wav') continue print(masterName[pluIndex]) quantity = input("Type the quantity: ") isDigit = pyFunctions01.checkDigit(str(quantity)) if isDigit == 0: # The character contained a non-numerical entry playBuzzer('Buzzer.wav') print("The quantity contained a non-numerical entry") continue if len(str(quantity)) > 4: playBuzzer('Buzzer.wav') print("The quantity is too large, please scan that pack again.") print("If you meant to enter more than 4 digits, please split") print("the quantity by scanning the PLU twice.") continue elif str(quantity) == '': playBuzzer('Buzzer.wav') print("You entered nothing for quantity.") print("Please enter the PLU again.") continue with open('pluListTemp.txt','a') as pluFile: pluFile.write(str(pluName)) pluFile.write('\n') with open('quantityListTemp.txt','a') as quantityFile: quantityFile.write(str(quantity)) quantityFile.write('\n') #pluList.append(pluName) #quantityList.append(quantity) #newList.append(str(pluList[counter1])+" "+str(quantityList[counter1])+str("\n")) counter1=counter1+1 newPluFile = open('pluListTemp.txt','r') pluList = newPluFile.read() pluList = pluList.split() newQuantityFile = open('quantityListTemp.txt','r') quantityList = newQuantityFile.read() quantityList = quantityList.split() newPluFile.close() newQuantityFile.close() newPluFile = open('pluListTemp.txt','w') #newPluFile.write() newPluFile.close() newQuantityFile = open('quantityListTemp.txt','w') #newQuantityFile.write() newQuantityFile.close() pluList,quantityList = pyFunctions01.combineList(pluList,quantityList,1) #pluList,quantityList = combinePLUs(pluList,quantityList) # Find inventory file, make two lists of PLUs and Quantities inventoryFile = open('Master Inventory.txt', 'r') inventory = inventoryFile.readlines() inventoryFile.close() inventoryPLUList = [] inventoryQuantityList = [] inventoryTest = inventory[-1].split() if len(inventoryTest) < 3: for i in range(len(inventory)-1): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) else: for i in range(len(inventory)): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) # Fix the file to include equiv PLUs for i in range(len(pluList)-1,-1,-1): currentPLU = pluList[i] masterListLocation = masterPLU.index(currentPLU) if masterEquivPLU[masterListLocation] != '0': # If there is an equiv, PLU isn't 0 multQuantity = float(quantityList[i])*float(masterEquivQnt[masterListLocation]) # Makes the actual quantity newEquivPLU = masterEquivPLU[masterListLocation] # name of equiv PLU (now real PLU) try: pluListLocation = pluList.index(newEquivPLU) # finds location of PLU in presented list oldQnt = quantityList[pluListLocation] # pulls quantity from this memory location quantityList[pluListLocation] = float(multQuantity)+float(oldQnt) # adds the two quantities together into memory location except ValueError: pluList.append(masterEquivPLU[masterListLocation]) quantityList.append(multQuantity) pluList.pop(i) # destroys original PLU quantityList.pop(i) # destroys original Quantity # Check to make sure the inventory file matches the current PLU and quantity lists errorPLU=[] errorQuantity=[] errorName=[] errorPrice=[] currentNameList = [] currentPriceList = [] for i in range(len(inventoryPLUList)): currentPLU = inventoryPLUList[i] masterListLocation = masterPLU.index(currentPLU) currentNameList.append(masterName[masterListLocation]) currentPriceList.append(masterPrice[masterListLocation]) try: beginListLocation = pluList.index(currentPLU) if float(inventoryQuantityList[i]) != float(quantityList[beginListLocation]): print("Your quantities do not match previous entries.") print("If you have added inventory, please use the add inventory program.") print("Otherwise, the following PLU does not match the inventory sheet") print("Previous Inventory:", inventoryPLUList[i], inventoryQuantityList[i]) print("Your Inventory:", pluList[beginListLocation], quantityList[beginListLocation]) print("Product Name:", masterName[masterListLocation]) print("Please check the values and indictate which is correct") try: quantityUpdate = eval(input("Please enter the correct inventory value: ")) except ValueError: print("You didn't enter a number!") continue if quantityUpdate != float(inventoryQuantityList[i]): errorPLU.append(inventoryPLUList[i]) errorQuantity.append(str(float(inventoryQuantityList[i])-quantityUpdate)) errorName.append(masterName[masterListLocation]) errorPrice.append(masterPrice[masterListLocation]) quantityList[beginListLocation] = quantityUpdate inventoryQuantityList[i] = quantityUpdate except ValueError: if float(inventoryQuantityList[i]) != 0: # because the value was not entered, if there is a value error print("Your quantities do not match previous entries.") print("If you have added inventory, please use the add inventory program.") print("Otherwise, the following PLU does not match the inventory sheet") print("Previous Inventory:", inventoryPLUList[i], inventoryQuantityList[i]) print("You did not scan the item.") print("Product Name:", masterName[masterListLocation]) print("Please check the values and indictate which is correct") try: quantityUpdate = eval(input("Please enter the correct inventory value: ")) except ValueError: print("You didn't enter a number!") continue if quantityUpdate != float(inventoryQuantityList[i]): errorPLU.append(inventoryPLUList[i]) errorQuantity.append(str(float(inventoryQuantityList[i])-quantityUpdate)) errorName.append(masterName[masterListLocation]) errorPrice.append(masterPrice[masterListLocation]) quantityList[beginListLocation] = quantityUpdate inventoryQuantityList[i] = quantityUpdate print("The inventory lists now match") # Create error file if errorPLU != []: createFile(errorPLU, errorName, errorQuantity, errorPrice, errorFileName) print("An error report has been generated, as the previous count was not correct.") # Create new file createFile(inventoryPLUList, currentNameList, inventoryQuantityList, currentPriceList, newFileName) print("Your inventory sheet has been created.") # Update inventory file createFile(inventoryPLUList, currentNameList, inventoryQuantityList, currentPriceList, 'Master Inventory.txt') print("The master inventory sheet has been updated.") input("Press 'Enter' to close")
def main(): import pyFunctions01 masterPLU = open('Master PLU List.txt', 'r') pluNameList = masterPLU.readlines() masterPLU.close() masterPLU = [] masterName = [] masterPrice = [] masterEquivPLU = [] masterEquivQnt = [] for i in range(len(pluNameList)): masterList = pluNameList[i].split() masterPLU.append(masterList[0]) masterName.append(masterList[1:-3]) masterPrice.append(masterList[-3]) masterEquivPLU.append(masterList[-2]) masterEquivQnt.append(masterList[-1]) import time name = input("Your Name (First Last): ") date = time.strftime("%Y,%m,%d %H,%M,%S") # Create file name year = date[0:4] month = date[4:6] day = date[6:8] nameList = name.split(" ") lastName = nameList[-1] firstName = nameList[0] newFileName = date + " " + "BEGIN" + " " + lastName + " " + firstName + ".txt" errorFileName = date + " " + "ERROR" + " " + lastName + " " + firstName + ".txt" # Gather PLU information (plu, amt) counter1 = 0 pluList = [] quantityList = [] newList = [] while True: pluName = input("Type or scan the PLU: ") if pluName == 'END': break else: pluExists, pluIndex = checkPLU(pluName, masterPLU) if pluExists == 0: playBuzzer('Buzzer.wav') continue print(masterName[pluIndex]) quantity = input("Type the quantity: ") isDigit = pyFunctions01.checkDigit(str(quantity)) if isDigit == 0: # The character contained a non-numerical entry playBuzzer('Buzzer.wav') print("The quantity contained a non-numerical entry") continue if len(str(quantity)) > 4: playBuzzer('Buzzer.wav') print("The quantity is too large, please scan that pack again.") print("If you meant to enter more than 4 digits, please split") print("the quantity by scanning the PLU twice.") continue elif str(quantity) == '': playBuzzer('Buzzer.wav') print("You entered nothing for quantity.") print("Please enter the PLU again.") continue with open('pluListTemp.txt', 'a') as pluFile: pluFile.write(str(pluName)) pluFile.write('\n') with open('quantityListTemp.txt', 'a') as quantityFile: quantityFile.write(str(quantity)) quantityFile.write('\n') #pluList.append(pluName) #quantityList.append(quantity) #newList.append(str(pluList[counter1])+" "+str(quantityList[counter1])+str("\n")) counter1 = counter1 + 1 newPluFile = open('pluListTemp.txt', 'r') pluList = newPluFile.read() pluList = pluList.split() newQuantityFile = open('quantityListTemp.txt', 'r') quantityList = newQuantityFile.read() quantityList = quantityList.split() newPluFile.close() newQuantityFile.close() newPluFile = open('pluListTemp.txt', 'w') #newPluFile.write() newPluFile.close() newQuantityFile = open('quantityListTemp.txt', 'w') #newQuantityFile.write() newQuantityFile.close() pluList, quantityList = pyFunctions01.combineList(pluList, quantityList, 1) #pluList,quantityList = combinePLUs(pluList,quantityList) # Find inventory file, make two lists of PLUs and Quantities inventoryFile = open('Master Inventory.txt', 'r') inventory = inventoryFile.readlines() inventoryFile.close() inventoryPLUList = [] inventoryQuantityList = [] inventoryTest = inventory[-1].split() if len(inventoryTest) < 3: for i in range(len(inventory) - 1): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) else: for i in range(len(inventory)): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) # Fix the file to include equiv PLUs for i in range(len(pluList) - 1, -1, -1): currentPLU = pluList[i] masterListLocation = masterPLU.index(currentPLU) if masterEquivPLU[ masterListLocation] != '0': # If there is an equiv, PLU isn't 0 multQuantity = float(quantityList[i]) * float( masterEquivQnt[masterListLocation] ) # Makes the actual quantity newEquivPLU = masterEquivPLU[ masterListLocation] # name of equiv PLU (now real PLU) try: pluListLocation = pluList.index( newEquivPLU) # finds location of PLU in presented list oldQnt = quantityList[ pluListLocation] # pulls quantity from this memory location quantityList[pluListLocation] = float(multQuantity) + float( oldQnt ) # adds the two quantities together into memory location except ValueError: pluList.append(masterEquivPLU[masterListLocation]) quantityList.append(multQuantity) pluList.pop(i) # destroys original PLU quantityList.pop(i) # destroys original Quantity # Check to make sure the inventory file matches the current PLU and quantity lists errorPLU = [] errorQuantity = [] errorName = [] errorPrice = [] currentNameList = [] currentPriceList = [] for i in range(len(inventoryPLUList)): currentPLU = inventoryPLUList[i] masterListLocation = masterPLU.index(currentPLU) currentNameList.append(masterName[masterListLocation]) currentPriceList.append(masterPrice[masterListLocation]) try: beginListLocation = pluList.index(currentPLU) if float(inventoryQuantityList[i]) != float( quantityList[beginListLocation]): print("Your quantities do not match previous entries.") print( "If you have added inventory, please use the add inventory program." ) print( "Otherwise, the following PLU does not match the inventory sheet" ) print("Previous Inventory:", inventoryPLUList[i], inventoryQuantityList[i]) print("Your Inventory:", pluList[beginListLocation], quantityList[beginListLocation]) print("Product Name:", masterName[masterListLocation]) print("Please check the values and indictate which is correct") try: quantityUpdate = eval( input("Please enter the correct inventory value: ")) except ValueError: print("You didn't enter a number!") continue if quantityUpdate != float(inventoryQuantityList[i]): errorPLU.append(inventoryPLUList[i]) errorQuantity.append( str(float(inventoryQuantityList[i]) - quantityUpdate)) errorName.append(masterName[masterListLocation]) errorPrice.append(masterPrice[masterListLocation]) quantityList[beginListLocation] = quantityUpdate inventoryQuantityList[i] = quantityUpdate except ValueError: if float( inventoryQuantityList[i] ) != 0: # because the value was not entered, if there is a value error print("Your quantities do not match previous entries.") print( "If you have added inventory, please use the add inventory program." ) print( "Otherwise, the following PLU does not match the inventory sheet" ) print("Previous Inventory:", inventoryPLUList[i], inventoryQuantityList[i]) print("You did not scan the item.") print("Product Name:", masterName[masterListLocation]) print("Please check the values and indictate which is correct") try: quantityUpdate = eval( input("Please enter the correct inventory value: ")) except ValueError: print("You didn't enter a number!") continue if quantityUpdate != float(inventoryQuantityList[i]): errorPLU.append(inventoryPLUList[i]) errorQuantity.append( str(float(inventoryQuantityList[i]) - quantityUpdate)) errorName.append(masterName[masterListLocation]) errorPrice.append(masterPrice[masterListLocation]) quantityList[beginListLocation] = quantityUpdate inventoryQuantityList[i] = quantityUpdate print("The inventory lists now match") # Create error file if errorPLU != []: createFile(errorPLU, errorName, errorQuantity, errorPrice, errorFileName) print( "An error report has been generated, as the previous count was not correct." ) # Create new file createFile(inventoryPLUList, currentNameList, inventoryQuantityList, currentPriceList, newFileName) print("Your inventory sheet has been created.") # Update inventory file createFile(inventoryPLUList, currentNameList, inventoryQuantityList, currentPriceList, 'Master Inventory.txt') print("The master inventory sheet has been updated.") input("Press 'Enter' to close")
def createSales(): import glob from datetime import date import pyFunctions01 #print("This program assumes that it is dealing with any range of files with arbitrary names.") #print("It will then take only files with the word 'begin', and create sales files based on date.") #print() print("Available Sales Files:",end='\n') functionBeginAdd = '????,??,?? ??,??,?? [AB][ED][GD]??*.txt' beginAddFiles = glob.glob(functionBeginAdd) ## for fileName in beginAddFiles: ## currentFile = open(fileName,'r') ## if currentFile.find('BEGIN') == -1: # The file is an add file ## # Then subtract the add file from the sales file beginFile = glob.glob('*BEGIN*.txt') addFile = glob.glob('*ADD*.txt') ## # For every day, create a new sales file ## firstBegin = beginFile[0] ## lastBegin = beginFile[-1] ## d0 = date(int(firstBegin[0:4]),int(firstBegin[5:7]),int(firstBegin[8:10])) ## d1 = date(int(lastBegin[0:4]),int(lastBegin[5:7]),int(lastBegin[8:10])) ## delta = d1-d0 ## daysBetween = delta.days # Doesn't include the last day # Remove all begin files except the first one for every day newBeginFile = [] newBeginFile.append(beginFile[0]) # Adds the first date for i in range(len(beginFile)-1): currentFile = beginFile[i] nextFile = beginFile[i+1] if currentFile[0:10] == nextFile[0:10]: # The files are of the same date continue else: # the files don't have the same date, therefore the next file is good newBeginFile.append(nextFile) #print(newBeginFile) # Combine add files which occured on the same day into the first one addFileTemp = [] for i in range(len(addFile)-1): currentFile = addFile[i] nextFile = addFile[i+1] if currentFile[0:10] == nextFile[0:10]: # The files have the same date addFileTemp.append(currentFile) # build a list of files w/ same date else: # The files don't have the same date (we moved on) addFileTemp.append(currentFile) # but we missed this one # Now put them into one file pluList = [] quantityList = [] for fileName in addFileTemp: currentFile = open(fileName,'r') fullList = currentFile.readlines() currentFile.close() # quantityInfo = fullList.pop() totalList = [] for i in range(len(fullList)): newSplit = fullList[i].split() currentPLU = newSplit[0] if len(newSplit) == 2: currentQuantity = newSplit[-1] else: currentQuantity = newSplit[-2] pluList.append(currentPLU) quantityList.append(currentQuantity) # Combine those lists together pluList,quantityList = pyFunctions01.combineList(pluList,quantityList,1) # Write the combined list to the first add in the temp file writeFile = open(addFileTemp[0],'w') totalList = [] for i in range(len(pluList)): currentTotal = str(pluList[i])+" "+str(quantityList[i])+str("\n") totalList.append(currentTotal) totalStr = '' for i in range(len(totalList)): totalStr = totalStr + str(totalList[i]) writeFile.write(totalStr) writeFile.close() addFileTemp = [] # totalList = [] # totalStr = '' fullList = [] # Combine the add files together, much like the begin files (such that only the first) # is listed newAddFile = [] newAddFile.append(addFile[0]) # Adds the first date for i in range(len(addFile)-1): currentFile = addFile[i] nextFile = addFile[i+1] if currentFile[0:10] == nextFile[0:10]: # The files are of the same date continue else: # the files don't have the same date, therefore the next file is good newAddFile.append(nextFile) ## for i in range(daysBetween): ## dayNumber = i+1 #print(newBeginFile) # Subtract each beginning file from the next, use that to estimate sales salesPLUList = [] salesQuantityList= [] for i in range(len(newBeginFile)-1): todayFileName2 = newBeginFile[i] #print(todayFileName) tomorrowFileName = newBeginFile[i+1] todayDate = todayFileName2[0:10] todayFileName = str("SALES")+" "+str(todayDate)+str('.txt') # Combine today and tomorrow file, today first f1 = open(todayFileName2,'r') todayFile = f1.readlines() todayFile.pop() f1.close() todayPLUList = [] todayQuantityList = [] for i in range(len(todayFile)): newSplit = todayFile[i].split() currentPLU = newSplit[0] if len(newSplit) == 2: currentQuantity = newSplit[-1] else: currentQuantity = newSplit[-2] todayPLUList.append(currentPLU) todayQuantityList.append(currentQuantity) # todayFileFull = '' # for i in range(len(todayPLUList)): # todayFileFull = todayFileFull + str(todayPLUList[i])+" "+str(todayQuantityList[i])+str("\n") f1 = open(tomorrowFileName,'r') tomorrowFile = f1.readlines() tomorrowFile.pop() f1.close() tomorrowPLUList = [] tomorrowQuantityList = [] for i in range(len(tomorrowFile)): newSplit = tomorrowFile[i].split() currentPLU = newSplit[0] if len(newSplit) == 2: currentQuantity = newSplit[-1] else: currentQuantity = newSplit[-2] tomorrowPLUList.append(currentPLU) tomorrowQuantityList.append(currentQuantity) # tomorrowFileFull = '' # for i in range(len(tomorrowPLUList)): # tomorrowFileFull = tomorrowFileFull + str(tomorrowPLUList[i]) +" "+str(tomorrowQuantityList[i])+str("\n") # with open(todayFileName,'a') as myfile: # myfile.write(tomorrowFileFull) #print(tomorrowFile) ## f2 = open(todayFileName,'a') ## f2.write(tomorrowFile) ## f2.close() # Now today is today followed by tomorrow, subtract to get to sales # fullList = [] # f3 = open(todayFileName,'r') # bigSales = f3.readlines() # f3.close() salesPLUList = [] salesQuantityList = [] for i in range(len(todayPLUList)): salesPLUList.append(todayPLUList[i]) salesQuantityList.append(todayQuantityList[i]) for i in range(len(tomorrowPLUList)): salesPLUList.append(tomorrowPLUList[i]) salesQuantityList.append(tomorrowQuantityList[i]) # salesPLUList = [] # salesQuantityList = [] # for i in range(len(bigSales)): # newSplit = bigSales[i].split() #print(newSplit) # currentPLU = newSplit[0] # if len(newSplit) == 2: # currentQuantity = newSplit[-1] # else: # currentQuantity = newSplit[-2] # salesPLUList.append(currentPLU) # salesQuantityList.append(currentQuantity) # Once we make the sales quantity and PLU list, send that to the subtraction method of # pyFunctions01 #print(salesPLUList) #print(salesQuantityList) salesPLUList,salesQuantityList = pyFunctions01.combineList(salesPLUList,salesQuantityList,3) # Add back in any add file associated to this day # Build my list of add files for fileName in newAddFile: #print(fileName) if fileName.find(todayDate) == -1: # This add file doesn't have the correct date addPLUList = [] addQuantityList = [] continue ## try: ## len(addPLUList) ## continue ## except NameError: ## addPLUList = [] ## continue else: # This add file does have the correct date #print(fileName) f4 = open(fileName,'r') currentAddFile = f4.readlines() f4.close() currentAddFile.pop() addPLUList = [] addQuantityList = [] for i in range(len(currentAddFile)): newSplit = currentAddFile[i].split() addPLU = newSplit[0] if len(newSplit) == 2: addQuantity = newSplit[-1] else: addQuantity = newSplit[-2] addPLUList.append(addPLU) addQuantityList.append(addQuantity) # Now that we have an add list, we can combine that list with the PLU List #print(addQuantityList) for i in range(len(addPLUList)): salesPLUList.append(addPLUList[i]) salesQuantityList.append(addQuantityList[i]) #print(salesQuantityList) salesPLUList,salesQuantityList = pyFunctions01.combineList(salesPLUList,salesQuantityList,1) #print(salesQuantityList) # Create the file using these two lists totalStr = '' for i in range(len(salesPLUList)): totalStr = totalStr + str(salesPLUList[i])+" "+str(salesQuantityList[i])+str("\n") #print(totalStr) # Once the total string exists, simply create a new file w/ the proper name # print(totalStr) file = open(todayFileName,'w') file.write(totalStr) file.close() print(todayFileName)
def main(): import pyFunctions01 masterPLU = open('Master PLU List.txt','r') pluNameList = masterPLU.readlines() masterPLU.close() masterPLU = [] masterName = [] masterPrice = [] masterEquivPLU = [] masterEquivQnt = [] for i in range(len(pluNameList)): masterList = pluNameList[i].split() masterPLU.append(masterList[0]) masterName.append(masterList[1:-3]) masterPrice.append(masterList[-3]) masterEquivPLU.append(masterList[-2]) masterEquivQnt.append(masterList[-1]) import time name = input("Your Name (First Last): ") date = time.strftime("%Y,%m,%d %H,%M,%S") nameList = name.split(" ") lastName = nameList[-1] firstName = nameList[0] newFileName = date+" "+"END"+" "+lastName+" "+firstName+".txt" salesFileName = date+" "+"SALES"+" "+lastName+" "+firstName+".txt" pluList = [] quantityList = [] newList = [] while True: print("Scan a PLU, or type a quantity then scan the PLU") pluName = input("Type or scan the PLU: ") if pluName == 'END': break else: # Break the quantity from the actual PLU if len(str(pluName)) == 8: # The quantity is apparently 1 quantity = 1 if len(str(pluName)) > 8: # The quantity is the first n digits quantity = eval(pluName[:-8]) pluName = pluName[-8:] pluExists,pluIndex = checkPLU(pluName,masterPLU) if pluExists == 0: playBuzzer('Buzzer.wav') continue print(masterName[pluIndex]) print("You sold",quantity) isDigit = pyFunctions01.checkDigit(str(quantity)) if isDigit == 0: # The character contained a non-numerical entry playBuzzer('Buzzer.wav') print("The quantity contained a non-numerical entry") continue if len(str(quantity)) > 4: playBuzzer('Buzzer.wav') print("The quantity is too large, please scan the pack again.") print("If you meant to enter more than 4 digits, please split") print("the quantity by scanning the PLU twice.") continue with open('pluListTemp.txt','a') as pluFile: pluFile.write(str(pluName)) pluFile.write('\n') with open('quantityListTemp.txt','a') as quantityFile: quantityFile.write(str(quantity)) quantityFile.write('\n') newPluFile = open('pluListTemp.txt','r') pluList = newPluFile.read() pluList = pluList.split() newQuantityFile = open('quantityListTemp.txt','r') quantityList = newQuantityFile.read() quantityList = quantityList.split() newPluFile.close() newQuantityFile.close() newPluFile = open('pluListTemp.txt','w') newPluFile.close() newQuantityFile = open('quantityListTemp.txt','w') newQuantityFile.close() pluList,quantityList = pyFunctions01.combineList(pluList,quantityList,1) inventoryFile = open('Master Inventory.txt','r') inventory = inventoryFile.readlines() inventoryFile.close() inventoryPLUList = [] inventoryQuantityList = [] inventoryTest = inventory[-1].split() if len(inventoryTest) < 3: for i in range(len(inventory)-1): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) else: for i in range(len(inventory)): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) # Fix the file to include equiv PLUs for i in range(len(pluList)-1,-1,-1): currentPLU = pluList[i] masterListLocation = masterPLU.index(currentPLU) if masterEquivPLU[masterListLocation] != '0': # If there is an equiv, PLU isn't 0 multQuantity = float(quantityList[i])*float(masterEquivQnt[masterListLocation]) # Makes the actual quantity newEquivPLU = masterEquivPLU[masterListLocation] # name of equiv PLU (now real PLU) try: pluListLocation = pluList.index(newEquivPLU) # finds location of PLU in presented list oldQnt = quantityList[pluListLocation] # pulls quantity from this memory location quantityList[pluListLocation] = float(multQuantity)+float(oldQnt) # adds the two quantities together into memory location except ValueError: pluList.append(masterEquivPLU[masterListLocation]) quantityList.append(multQuantity) pluList.pop(i) # destroys original PLU quantityList.pop(i) # destroys original Quantity currentNameList = [] currentPriceList = [] for i in range(len(inventoryPLUList)): # This loop is questionable currentPLU = inventoryPLUList[i] masterListLocation = masterPLU.index(currentPLU) currentNameList.append(masterName[masterListLocation]) currentPriceList.append(masterPrice[masterListLocation]) # Put inventoryPLU together with currentPLU, inventoryQuantity w/ currentQuantity inventoryTempPLUList = [] inventoryTempQuantityList = [] for i in range(len(inventoryPLUList)): inventoryTempPLUList.append(inventoryPLUList[i]) inventoryTempQuantityList.append(inventoryQuantityList[i]) salesPLUList = [] salesQuantityList = [] for i in range(len(pluList)): currentPLU = pluList[i] currentQuantity = quantityList[i] salesPLUList.append(currentPLU) salesQuantityList.append(currentQuantity) inventoryTempPLUList.append(currentPLU) inventoryTempQuantityList.append(currentQuantity) # Subtract sales inventoryTempPLUList,inventoryTempQuantityList = pyFunctions01.combineList(inventoryTempPLUList,inventoryTempQuantityList,3) print("Your inventory has been stored.") # Update inventory file createFile(inventoryTempPLUList,currentNameList,inventoryTempQuantityList,currentPriceList, 'Master Inventory.txt') print("The master inventory sheet has been updated.") # Create new cashier inventory file createFile(inventoryTempPLUList,currentNameList,inventoryTempQuantityList,currentPriceList, newFileName) print("Your inventory sheet has been created.") # Create a sales file createFile(salesPLUList,currentNameList,salesQuantityList,currentPriceList,salesFileName) print("Your sales sheet has been created.") input("Press 'Enter' to close")
def main(): import pyFunctions01 masterPLU = open('Master PLU List.txt', 'r') pluNameList = masterPLU.readlines() masterPLU.close() masterPLU = [] masterName = [] masterPrice = [] masterEquivPLU = [] masterEquivQnt = [] for i in range(len(pluNameList)): masterList = pluNameList[i].split() masterPLU.append(masterList[0]) masterName.append(masterList[1:-3]) masterPrice.append(masterList[-3]) masterEquivPLU.append(masterList[-2]) masterEquivQnt.append(masterList[-1]) import time name = input("Your Name (First Last): ") date = time.strftime("%Y,%m,%d %H,%M,%S") # Create file name ## year = date[0:4] ## month = date[4:6] ## day = date[6:8] nameList = name.split(" ") lastName = nameList[-1] firstName = nameList[0] newFileName = date + " " + "END" + " " + lastName + " " + firstName + ".txt" salesFileName = date + " " + "SALES" + " " + lastName + " " + firstName + ".txt" # Gather PLU information (plu, amt) counter1 = 0 pluList = [] quantityList = [] newList = [] while True: pluName = input("Type or scan the PLU: ") if pluName == 'END': break else: pluExists, pluIndex = checkPLU(pluName, masterPLU) if pluExists == 0: playBuzzer('Buzzer.wav') continue print(masterName[pluIndex]) quantity = input("Type the quantity: ") isDigit = pyFunctions01.checkDigit(str(quantity)) if isDigit == 0: # The character contained a non-numerical entry playBuzzer('Buzzer.wav') print("The quantity contained a non-numerical entry") continue if len(str(quantity)) > 4: playBuzzer('Buzzer.wav') print("The quantity is too large, please scan that pack again.") print("If you meant to enter more than 4 digits, please split") print("the quantity by scanning the PLU twice.") continue elif str(quantity) == '': playBuzzer('Buzzer.wav') print("You entered nothing for quantity.") print("Please enter the PLU again.") continue with open('pluListTemp.txt', 'a') as pluFile: pluFile.write(str(pluName)) pluFile.write('\n') with open('quantityListTemp.txt', 'a') as quantityFile: quantityFile.write(str(quantity)) quantityFile.write('\n') #pluList.append(pluName) #quantityList.append(quantity) #newList.append(str(pluList[counter1])+" "+str(quantityList[counter1])+str("\n")) counter1 = counter1 + 1 newPluFile = open('pluListTemp.txt', 'r') pluList = newPluFile.read() pluList = pluList.split() newQuantityFile = open('quantityListTemp.txt', 'r') quantityList = newQuantityFile.read() quantityList = quantityList.split() newPluFile.close() newQuantityFile.close() newPluFile = open('pluListTemp.txt', 'w') #newPluFile.write() newPluFile.close() newQuantityFile = open('quantityListTemp.txt', 'w') #newQuantityFile.write() newQuantityFile.close() pluList, quantityList = pyFunctions01.combineList(pluList, quantityList, 1) #pluList,quantityList = combinePLUs(pluList,quantityList) # Find inventory file, make two lists of PLUs and Quantities inventoryFile = open('Master Inventory.txt', 'r') inventory = inventoryFile.readlines() inventoryFile.close() inventoryPLUList = [] inventoryQuantityList = [] inventoryTest = inventory[-1].split() if len(inventoryTest) < 3: for i in range(len(inventory) - 1): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) else: for i in range(len(inventory)): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) # Fix the file to include equiv PLUs for i in range(len(pluList) - 1, -1, -1): currentPLU = pluList[i] masterListLocation = masterPLU.index(currentPLU) if masterEquivPLU[ masterListLocation] != '0': # If there is an equiv, PLU isn't 0 multQuantity = float(quantityList[i]) * float( masterEquivQnt[masterListLocation] ) # Makes the actual quantity newEquivPLU = masterEquivPLU[ masterListLocation] # name of equiv PLU (now real PLU) try: pluListLocation = pluList.index( newEquivPLU) # finds location of PLU in presented list oldQnt = quantityList[ pluListLocation] # pulls quantity from this memory location quantityList[pluListLocation] = float(multQuantity) + float( oldQnt ) # adds the two quantities together into memory location except ValueError: pluList.append(masterEquivPLU[masterListLocation]) quantityList.append(multQuantity) pluList.pop(i) # destroys original PLU quantityList.pop(i) # destroys original Quantity # Check to make sure the inventory file matches the current PLU and quantity lists salesPLU = [] salesQuantity = [] salesName = [] salesPrice = [] currentNameList = [] currentPriceList = [] for i in range(len(inventoryPLUList)): currentPLU = inventoryPLUList[i] masterListLocation = masterPLU.index(currentPLU) currentNameList.append(masterName[masterListLocation]) currentPriceList.append(masterPrice[masterListLocation]) try: beginListLocation = pluList.index(currentPLU) if int(quantityList[beginListLocation]) > int( inventoryQuantityList[i]): print( "Your inventory Quantity is greater than previous entries." ) print("Please use the inventory add function to add cartons.") print("The following PLU is greater than the inventory sheet") print("Previous Inventory:", inventoryPLUList[i], inventoryQuantityList[i]) print("Your inventory:", pluList[beginListLocation], quantityList[beginListLocation]) print("Product Name:", masterName[masterListLocation]) try: realQuantity = eval( input("Please enter the correct quantity: ")) except ValueError: print("You didn't enter a number!") continue if float(realQuantity) != float(inventoryQuantityList[i]): inventoryQuantityList[i] = float(realQuantity) quantityList[beginListLocation] = realQuantity elif float(quantityList[beginListLocation]) < float( inventoryQuantityList[i]): soldQuantity = float(inventoryQuantityList[i]) - float( quantityList[beginListLocation]) salesPLU.append(pluList[beginListLocation]) salesQuantity.append(str(soldQuantity)) salesName.append(masterName[masterListLocation]) salesPrice.append(masterPrice[masterListLocation]) except ValueError: # A previously designated PLU that exists in inventory doesn't exist in the current list. #beginListLocation = pluList.index(currentPLU) if float(inventoryQuantityList[i]) == 0: # The PLU is at 0 in the inventory system # Pass through continue else: print("You did not enter a value for the following PLU") print("Previous Value:", inventoryPLUList[i], inventoryQuantityList[i]) print("Product Name:", masterName[masterListLocation]) try: realQuantity = eval( input("Please enter the correct quantity: ")) except ValueError: print("You didn't enter a number!") continue if float(realQuantity) != float(inventoryQuantityList[i]): inventoryQuantityList[i] = float(realQuantity) # Append the value to the pluList and quantityList... pluList.append(inventoryPLUList[i]) quantityList.append(inventoryQuantityList[i]) ## if int(inventoryQuantityList[i]) != 0: ## if int(quantityList[beginListLocation]) > int(inventoryQuantityList[i]): ## print("Your inventory Quantity is greater than previous entries.") ## print("Please use the inventory add function to add cartons.") ## print("The following PLU is greater than the inventory sheet") ## print("Previous Inventory:", inventoryPLUList[i], inventoryQuantityList[i]) ## print("Your inventory:", pluList[beginListLocation], quantityList[beginListLocation]) ## print("Product Name:", masterName[masterListLocation]) ## try: ## realQuantity = input("Please enter the correct quantity: ") ## except ValueError: ## print("You didn't enter a number!") ## continue ## if int(realQuantity) != int(inventoryQuantityList[i]): ## inventoryQuantityList[i] = int(realQuantity) ## quantityList[beginListLocation] = realQuantity ## elif int(quantityList[beginListLocation]) < int(inventoryQuantityList[i]): ## soldQuantity = int(inventoryQuantityList[i]) - int(quantityList[beginListLocation]) ## salesPLU.append(pluList[beginListLocation]) ## salesQuantity.append(str(soldQuantity)) ## salesName.append(masterName[MasterListLocation]) ## salesPrice.append(masterPrice[masterListLocation]) for i in range(len(salesPLU)): currentPLU = salesPLU[i] inventoryIndex = inventoryPLUList.index(currentPLU) inventoryQuantityList[inventoryIndex] = float( inventoryQuantityList[inventoryIndex]) - float(salesQuantity[i]) inventoryQuantityList[inventoryIndex] = str( inventoryQuantityList[inventoryIndex]) print("Your inventory has been stored.") # Update inventory file createFile(inventoryPLUList, currentNameList, inventoryQuantityList, currentPriceList, 'Master Inventory.txt') print("The master inventory sheet has been updated.") # Create new cashier inventory file createFile(inventoryPLUList, currentNameList, inventoryQuantityList, currentPriceList, newFileName) print("Your inventory sheet has been created.") # Create sales file createFile(salesPLU, salesName, salesQuantity, salesPrice, salesFileName) print("Your sales sheet has been created.") input("Press 'Enter' to close")
def createSales(): import glob from datetime import date import pyFunctions01 #print("This program assumes that it is dealing with any range of files with arbitrary names.") #print("It will then take only files with the word 'begin', and create sales files based on date.") #print() print("Available Sales Files:", end='\n') functionBeginAdd = '????,??,?? ??,??,?? [AB][ED][GD]??*.txt' beginAddFiles = glob.glob(functionBeginAdd) ## for fileName in beginAddFiles: ## currentFile = open(fileName,'r') ## if currentFile.find('BEGIN') == -1: # The file is an add file ## # Then subtract the add file from the sales file beginFile = glob.glob('*BEGIN*.txt') addFile = glob.glob('*ADD*.txt') ## # For every day, create a new sales file ## firstBegin = beginFile[0] ## lastBegin = beginFile[-1] ## d0 = date(int(firstBegin[0:4]),int(firstBegin[5:7]),int(firstBegin[8:10])) ## d1 = date(int(lastBegin[0:4]),int(lastBegin[5:7]),int(lastBegin[8:10])) ## delta = d1-d0 ## daysBetween = delta.days # Doesn't include the last day # Remove all begin files except the first one for every day newBeginFile = [] newBeginFile.append(beginFile[0]) # Adds the first date for i in range(len(beginFile) - 1): currentFile = beginFile[i] nextFile = beginFile[i + 1] if currentFile[0:10] == nextFile[ 0:10]: # The files are of the same date continue else: # the files don't have the same date, therefore the next file is good newBeginFile.append(nextFile) #print(newBeginFile) # Combine add files which occured on the same day into the first one addFileTemp = [] for i in range(len(addFile) - 1): currentFile = addFile[i] nextFile = addFile[i + 1] if currentFile[0:10] == nextFile[0:10]: # The files have the same date addFileTemp.append( currentFile) # build a list of files w/ same date else: # The files don't have the same date (we moved on) addFileTemp.append(currentFile) # but we missed this one # Now put them into one file pluList = [] quantityList = [] for fileName in addFileTemp: currentFile = open(fileName, 'r') fullList = currentFile.readlines() currentFile.close() # quantityInfo = fullList.pop() totalList = [] for i in range(len(fullList)): newSplit = fullList[i].split() currentPLU = newSplit[0] if len(newSplit) == 2: currentQuantity = newSplit[-1] else: currentQuantity = newSplit[-2] pluList.append(currentPLU) quantityList.append(currentQuantity) # Combine those lists together pluList, quantityList = pyFunctions01.combineList( pluList, quantityList, 1) # Write the combined list to the first add in the temp file writeFile = open(addFileTemp[0], 'w') totalList = [] for i in range(len(pluList)): currentTotal = str(pluList[i]) + " " + str( quantityList[i]) + str("\n") totalList.append(currentTotal) totalStr = '' for i in range(len(totalList)): totalStr = totalStr + str(totalList[i]) writeFile.write(totalStr) writeFile.close() addFileTemp = [] # totalList = [] # totalStr = '' fullList = [] # Combine the add files together, much like the begin files (such that only the first) # is listed newAddFile = [] newAddFile.append(addFile[0]) # Adds the first date for i in range(len(addFile) - 1): currentFile = addFile[i] nextFile = addFile[i + 1] if currentFile[0:10] == nextFile[ 0:10]: # The files are of the same date continue else: # the files don't have the same date, therefore the next file is good newAddFile.append(nextFile) ## for i in range(daysBetween): ## dayNumber = i+1 #print(newBeginFile) # Subtract each beginning file from the next, use that to estimate sales salesPLUList = [] salesQuantityList = [] for i in range(len(newBeginFile) - 1): todayFileName2 = newBeginFile[i] #print(todayFileName) tomorrowFileName = newBeginFile[i + 1] todayDate = todayFileName2[0:10] todayFileName = str("SALES") + " " + str(todayDate) + str('.txt') # Combine today and tomorrow file, today first f1 = open(todayFileName2, 'r') todayFile = f1.readlines() todayFile.pop() f1.close() todayPLUList = [] todayQuantityList = [] for i in range(len(todayFile)): newSplit = todayFile[i].split() currentPLU = newSplit[0] if len(newSplit) == 2: currentQuantity = newSplit[-1] else: currentQuantity = newSplit[-2] todayPLUList.append(currentPLU) todayQuantityList.append(currentQuantity) # todayFileFull = '' # for i in range(len(todayPLUList)): # todayFileFull = todayFileFull + str(todayPLUList[i])+" "+str(todayQuantityList[i])+str("\n") f1 = open(tomorrowFileName, 'r') tomorrowFile = f1.readlines() tomorrowFile.pop() f1.close() tomorrowPLUList = [] tomorrowQuantityList = [] for i in range(len(tomorrowFile)): newSplit = tomorrowFile[i].split() currentPLU = newSplit[0] if len(newSplit) == 2: currentQuantity = newSplit[-1] else: currentQuantity = newSplit[-2] tomorrowPLUList.append(currentPLU) tomorrowQuantityList.append(currentQuantity) # tomorrowFileFull = '' # for i in range(len(tomorrowPLUList)): # tomorrowFileFull = tomorrowFileFull + str(tomorrowPLUList[i]) +" "+str(tomorrowQuantityList[i])+str("\n") # with open(todayFileName,'a') as myfile: # myfile.write(tomorrowFileFull) #print(tomorrowFile) ## f2 = open(todayFileName,'a') ## f2.write(tomorrowFile) ## f2.close() # Now today is today followed by tomorrow, subtract to get to sales # fullList = [] # f3 = open(todayFileName,'r') # bigSales = f3.readlines() # f3.close() salesPLUList = [] salesQuantityList = [] for i in range(len(todayPLUList)): salesPLUList.append(todayPLUList[i]) salesQuantityList.append(todayQuantityList[i]) for i in range(len(tomorrowPLUList)): salesPLUList.append(tomorrowPLUList[i]) salesQuantityList.append(tomorrowQuantityList[i]) # salesPLUList = [] # salesQuantityList = [] # for i in range(len(bigSales)): # newSplit = bigSales[i].split() #print(newSplit) # currentPLU = newSplit[0] # if len(newSplit) == 2: # currentQuantity = newSplit[-1] # else: # currentQuantity = newSplit[-2] # salesPLUList.append(currentPLU) # salesQuantityList.append(currentQuantity) # Once we make the sales quantity and PLU list, send that to the subtraction method of # pyFunctions01 #print(salesPLUList) #print(salesQuantityList) salesPLUList, salesQuantityList = pyFunctions01.combineList( salesPLUList, salesQuantityList, 3) # Add back in any add file associated to this day # Build my list of add files for fileName in newAddFile: #print(fileName) if fileName.find( todayDate ) == -1: # This add file doesn't have the correct date addPLUList = [] addQuantityList = [] continue ## try: ## len(addPLUList) ## continue ## except NameError: ## addPLUList = [] ## continue else: # This add file does have the correct date #print(fileName) f4 = open(fileName, 'r') currentAddFile = f4.readlines() f4.close() currentAddFile.pop() addPLUList = [] addQuantityList = [] for i in range(len(currentAddFile)): newSplit = currentAddFile[i].split() addPLU = newSplit[0] if len(newSplit) == 2: addQuantity = newSplit[-1] else: addQuantity = newSplit[-2] addPLUList.append(addPLU) addQuantityList.append(addQuantity) # Now that we have an add list, we can combine that list with the PLU List #print(addQuantityList) for i in range(len(addPLUList)): salesPLUList.append(addPLUList[i]) salesQuantityList.append(addQuantityList[i]) #print(salesQuantityList) salesPLUList, salesQuantityList = pyFunctions01.combineList( salesPLUList, salesQuantityList, 1) #print(salesQuantityList) # Create the file using these two lists totalStr = '' for i in range(len(salesPLUList)): totalStr = totalStr + str(salesPLUList[i]) + " " + str( salesQuantityList[i]) + str("\n") #print(totalStr) # Once the total string exists, simply create a new file w/ the proper name # print(totalStr) file = open(todayFileName, 'w') file.write(totalStr) file.close() print(todayFileName)
def main(): """ :rtype : object """ import pyFunctions01 masterPLU = open('Master PLU List.txt', 'r') pluNameList = masterPLU.readlines() masterPLU.close() masterPLU = [] masterName = [] masterPrice = [] masterEquivPLU = [] masterEquivQnt = [] for i in range(len(pluNameList)): masterList = pluNameList[i].split() masterPLU.append(masterList[0]) masterName.append(masterList[1:-3]) masterPrice.append(masterList[-3]) masterEquivPLU.append(masterList[-2]) masterEquivQnt.append(masterList[-1]) import time name = input("What is your Name (First Last): ") #date = input("What is the date (YYYYMMDD)?: ") date = time.strftime("%Y,%m,%d %H,%M,%S") # Create file name ## year = date[0:4] ## month = date[4:6] ## day = date[6:8] nameList = name.split(" ") lastName = nameList[-1] firstName = nameList[0] addFileName = date + " " + "ADD" + " " + lastName + " " + firstName + ".txt" # Gather PLU Information (plu, amt) counter1 = 0 pluList = [] quantityList = [] newList = [] while True: pluName = input("Type of scan the PLU (or 'END' to exit): ") if pluName == 'END': break else: pluExists, pluIndex = checkPLU(pluName, masterPLU) if pluExists == 0: playBuzzer('Buzzer.wav') continue print(masterName[pluIndex]) quantity = input("Type the quantity: ") isDigit = pyFunctions01.checkDigit(str(quantity)) if isDigit == 0: # The value is not a digit playBuzzer('Buzzer.wav') print( "There was a non-numerical character in your quantity string") continue if len(str(quantity)) > 4: print("The quantity is too large, please scan that pack again.") print("If you meant to enter more than 4 digits, please split") print("the quantity by scanning the PLU twice.") playBuzzer('Buzzer.wav') continue elif str(quantity) == '': print("You entered nothing for quantity.") print("Please enter the PLU again.") playBuzzer('Buzzer.wav') continue with open('pluListTemp.txt', 'a') as pluFile: pluFile.write(str(pluName)) pluFile.write('\n') with open('quantityListTemp.txt', 'a') as quantityFile: quantityFile.write(str(quantity)) quantityFile.write('\n') #quantityFile = open('quantityListTemp.txt','a') #pluList.append(pluName) #quantityList.append(quantity) counter1 = counter1 + 1 # Update the pluList and quantityList, adding all PLUs together. # This file takes time, pops both lists and recreates. newPluFile = open('pluListTemp.txt', 'r') pluList = newPluFile.read() pluList = pluList.split() newQuantityFile = open('quantityListTemp.txt', 'r') quantityList = newQuantityFile.read() quantityList = quantityList.split() newPluFile.close() newQuantityFile.close() newPluFile = open('pluListTemp.txt', 'w') #newPluFile.write() newPluFile.close() newQuantityFile = open('quantityListTemp.txt', 'w') #newQuantityFile.write() newQuantityFile.close() pluList, quantityList = pyFunctions01.combineList(pluList, quantityList, 1) #pluList,quantityList = combinePLUs(pluList,quantityList) # Find inventory file, make two lists of PLUs and Quantities inventoryFile = open('Master Inventory.txt', 'r') inventory = inventoryFile.readlines() inventoryFile.close() inventoryPLUList = [] inventoryQuantityList = [] inventoryTest = inventory[-1].split() if 3 > len(inventoryTest): for i in range(len(inventory) - 1): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) else: for i in range(len(inventory)): inventorySplit = inventory[i].split() inventoryPLU = inventorySplit[0] inventoryQuantity = inventorySplit[-2] inventoryPLUList.append(inventoryPLU) inventoryQuantityList.append(inventoryQuantity) # Fix the file to include equiv PLUs for i in range(len(pluList) - 1, -1, -1): currentPLU = pluList[i] masterListLocation = masterPLU.index(currentPLU) if masterEquivPLU[ masterListLocation] != '0': # If there is an equiv, PLU isn't 0 multQuantity = float(quantityList[i]) * float( masterEquivQnt[masterListLocation] ) # Makes the actual quantity newEquivPLU = masterEquivPLU[ masterListLocation] # name of equiv PLU (now real PLU) try: pluListLocation = pluList.index( newEquivPLU) # finds location of PLU in presented list oldQnt = quantityList[ pluListLocation] # pulls quantity from this memory location quantityList[pluListLocation] = float(multQuantity) + float( oldQnt ) # adds the two quantities together into memory location except ValueError: pluList.append(masterEquivPLU[masterListLocation]) quantityList.append(multQuantity) pluList.pop(i) # destroys original PLU quantityList.pop(i) # destroys original Quantity # Add names and prices to new inventory nameList = [] priceList = [] for i in range(len(pluList)): currentPLU = pluList[i] masterListLocation = masterPLU.index(currentPLU) nameList.append(masterName[masterListLocation]) priceList.append(masterPrice[masterListLocation]) inventoryNameList = [] inventoryPriceList = [] for i in range(len(inventoryPLUList)): currentPLU = inventoryPLUList[i] try: beginListLocation = pluList.index(str(currentPLU)) addedQuantity = float(quantityList[beginListLocation]) except ValueError: addedQuantity = 0 masterListLocation = masterPLU.index(currentPLU) currentQuantity = float(inventoryQuantityList[i]) newQuantity = currentQuantity + addedQuantity inventoryQuantityList[i] = str(newQuantity) inventoryNameList.append(masterName[masterListLocation]) inventoryPriceList.append(masterPrice[masterListLocation]) createFile(pluList, nameList, quantityList, priceList, addFileName) print("An add inventory file has been created.") createFile(inventoryPLUList, inventoryNameList, inventoryQuantityList, inventoryPriceList, 'Master Inventory.txt') print("The inventory file has been updated.") input("Press 'Enter' to close")