This is my invoicing program I made for myself to keep track of purchases people made from me. (Yes I know eBay does this for me but I wanted to see what I could make.) Basically it can search the invoice file for a keyword (the invoice number) or lets you enter a new invoice to a file named usb.txt. It is usb.txt because I was selling USB cables at the time.
#Invoice Entering Program Ebay
print("Ebay Invoice Program\n")
while True:
file = input("Enter 0 to Quit. Enter S to Search The File. Press ENTER to Input new Entries *Case Sensitive*: " )
if file == "0":
print("Exiting Program...")
break
elif file=="S":
keyword = input("Enter Invoice Number to Search For: ")
look_in = "usb.txt"
search_file = open(look_in,"r")
with open(look_in, "r") as search_file:
for line in search_file:
if keyword in line:
print(line)
else:
Name = input("Enter Buyer Name: ")
InNum = input("Enter Ebay Invoice Number: ")
Quant = int(input("Enter Amount Bought: "))
Price = Quant * 5
with open("usb.txt", "at")as out_file:
out_file.write(
"Name: %s || Invoice Number: %s || Quantity: %s || Price:$ %s \n\n" % (Name, InNum, Quant, Price))
out_file.close()
print("File edits made")
I'm pretty new to python and programming in general. If you have any suggestions on how I could improve it or any ideas to add functionality I'd love to hear it! This was written in python 3.5.1.