Advertisement
Guest User

Untitled

a guest
Mar 13th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. from pylab import *
  2. import re, datetime
  3.  
  4.  
  5. fig = figure()
  6. fig.subplots_adjust(bottom=0.2)
  7.  
  8. day_zero = datetime.date(2000, 1, 1)
  9.  
  10. data_lines = open('out_comments_time.txt').read().splitlines() + open('out_posting_time.txt').read().splitlines()
  11. data = []
  12.  
  13. for l in data_lines:
  14. l = l.strip()
  15. if not l:
  16. continue
  17. m = re.match('(xxxx)-(xx)-(xx) (xx):(xx):(xx)'.replace('x', '\\d'), l)
  18. assert m, repr(l)
  19. g = lambda i: int(m.group(i))
  20. if g(1) < 1500:
  21. continue
  22. dt = (datetime.date(g(1), g(2), g(3)) - day_zero)
  23. data.append((
  24. (dt.seconds + dt.days * 24 * 3600) / (365.25 * 24 * 60 * 60),
  25. (60*60*g(4) + 60*g(5) + g(6)) / 3600.0
  26. ))
  27. data.sort()
  28.  
  29. print min(data), max(data)
  30.  
  31.  
  32. grid()
  33. plot([a[0] for a in data], [a[1] for a in data],'bo', alpha=0.3)
  34.  
  35. show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement