Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Itemref = []
- Itemqty = []
- Itemqtysold = []
- indexVal = 0
- text = open("SampleData.txt","r")
- for line in text:
- Rline = line.split()
- if (Rline[0] != "OrderDate"):
- if(Rline[3] not in Itemref):
- Itemref.append(Rline[3])
- Itemqty.append(int(Rline[4]))
- Itemqtysold.append(float(Rline[6]))
- else:
- indexVal = Itemref.index(Rline[3])
- Itemqty[indexVal] += int(Rline[4])
- Itemqtysold[indexVal] += float(Rline[6])
- text.close()
- print("Item Qty sold Total")
- for a in range(len(Itemref)):
- print("%s %s %s"%(Itemref[a],Itemqty[a],Itemqtysold[a]))
Advertisement
Add Comment
Please, Sign In to add comment