#14-12-2012
#assignment Menu Program
#-------------------------------------
#open file and read data assining it to 2 dimension list def openFile(fileName): bufferFile = open(fileName) bufferTxt = bufferFile.read() bufferFile.close() bufferLines = bufferTxt.split("\n") bufferTable = [] ln=0 for line in bufferLines: if len(line) > 0: if ln != 0: dataLine = line.split(",") dataLine[0] = dataLine[0].capitalize() bufferTable = bufferTable + [dataLine] else: dataLine = line.split(",") for dt in dataLine: i = dataLine.index(dt) dataLine[i] = dt.upper() bufferTable = bufferTable + [dataLine] ln+=1 return bufferTable
#-------------------------------------
#-------------------------------------
#function to check if number less than 10 to add 0 in front
#(send 9 receive 09) def lessThan10(number): if number < 10: number = "0" + str(number) else: number = str(number) return number
#-------------------------------------
#-------------------------------------
#format price def formatPrice(pricesss): if float(pricesss) < 10: pricesss = "£ {:.2f}".format(float(pricesss)) else: pricesss = "£ {:.2f}".format(float(pricesss)) return pricesss
#-------------------------------------
#-------------------------------------
#print all Data in nice formated table def printallTable(): print(' '.ljust(25),'Full menu list of the dishes'.upper()) print('') ln = 0 for line in allTable: if ln!= 0: dishNo = lessThan10(ln) + " - " print(dishNo.ljust(5), line[0].ljust(12), line[1].ljust(30) ,formatPrice(line[2]).ljust(8),line[3].ljust(8)) else: print("No - ",line[0].ljust(12),