Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extract from Skynet to Plot.ly
from pymongo import Connection
import time
from datetime import datetime
import plotly
conn = Connection('localhost', 27017)
db = conn.skynet
collection = db.events
# 24 hour time range
time = int(round((time.time() - 86400) * 1000))
results = collection.find({
"timestamp": {"$gte" : time },
"uuid": "UUID"
})
x = []
y = []
for i in results:
if 'temperature' in i.keys():
ts= str(int(i['timestamp']))[:-3]
x.append(datetime.fromtimestamp(int(ts)))
y.append(str(i['temperature']))
# start time
#print x[0]
# end time
#print x[-1]
py = plotly.plotly("USERNAME", "PASSWORD")
py.plot(x,y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.