Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
151
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. count = 0.0
  18. total = 0.00
  19. nodeList = []
  20. oldKey = None
  21. for line in sys.stdin:
  22. smallData = ""
  23. data_mapped = line.strip().split("\t", 1)
  24. if len(data_mapped) != 2:
  25. continue
  26. thisKey, thisContent = data_mapped
  27. if oldKey and oldKey != thisKey:
  28. print "{0}\t{1}".format(oldKey,total)
  29. oldKey = thisKey;
  30. total = 0
  31. #count = 0
  32. oldKey = thisKey
  33. #count = count +1.0
  34. total = total + float(thisContent)
  35. print "{0}\t{1}".format("0",total)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement