Exemplo n.º 1
0
def extract(start=2003,end=2011,year=None):
  hours={}
  hour=3600
  days={}
  day=24*hour
  if year!=None:
    start=year
    end=year+1
  for year in range(start,end):
    infile='data/%d-rawtimes.csv' % year
    print 'Extracting from %s' % infile
    dts=fromfile(infile,year)
    dt_objs=[row['value'] for row in dts]
 
    for dt in dt_objs:
      posix=int(dt.strftime('%s'))
      # int truncates rather than rounds
      increment(hours,int(posix/hour)*hour)
      increment(days,int(posix/day)*day)
  return {"hours":hours,"days":days}