Skip to content

Instantly share code, notes, and snippets.

@bwghughes
Created April 3, 2013 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwghughes/5301587 to your computer and use it in GitHub Desktop.
Save bwghughes/5301587 to your computer and use it in GitHub Desktop.
import time
import json
import datetime
from random import randrange
from datetime import timedelta
def date_range():
start_date = datetime.datetime.now().date() - timedelta(days=-365)
for n in xrange(365):
yield start_date + timedelta(n)
def create_timeseries():
data = []
for date in date_range():
data.append({time.mktime(date.timetuple()): randrange(0, 60)})
return json.dumps(data)
if __name__ == "__main__":
json_data = create_timeseries()
print json_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment