Advertisement
Guest User

paste1

a guest
Nov 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import sys
  2.  
  3. salesTotal = 0
  4. oldKey = None
  5.  
  6. for line in sys.stdin:
  7. data = line.strip().split("\t")
  8. if len(data) != 2:
  9. # Something has gone wrong. Skip this line.
  10. continue
  11.  
  12. thisKey, thisSale = data
  13. if oldKey and oldKey != thisKey:
  14. print oldKey, "\t", salesTotal
  15. oldKey = thisKey
  16. salesTotal = 0
  17.  
  18. oldKey = thisKey
  19. salesTotal += float(thisSale)
  20.  
  21. if oldKey != None:
  22. print oldKey, "\t", salesTotal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement