Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. from datetime import datetime
  3. import sys
  4. import csv
  5. import re
  6.  
  7. reader = csv.reader(sys.stdin, delimiter = "\t")
  8.  
  9. for line in reader:
  10. date = line[0]
  11. weekday = weekday = datetime.strptime(date, "%Y-%m-%d").weekday()
  12. print "{0}\t{1}".format(weekday,line[4])
  13.  
  14. #!/usr/bin/python
  15.  
  16. import sys
  17. total = 0.00
  18. oldKey = None
  19. for line in sys.stdin:
  20. smallData = ""
  21. data_mapped = line.strip().split("\t", 1)
  22. if len(data_mapped) != 2:
  23. continue
  24. thisKey, thisContent = data_mapped
  25. if oldKey and oldKey != thisKey:
  26. print "{0}\t{1}".format(oldKey,total)
  27. oldKey = thisKey;
  28. total = 0
  29. oldKey = thisKey
  30. total = total + float(thisContent)
  31. print "{0}\t{1}".format("0",total)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement