Skip to content

Commit

Permalink
trying to make sense of data returned
Browse files Browse the repository at this point in the history
  • Loading branch information
Swizec committed Feb 11, 2012
1 parent bd8a3a2 commit 277b8e8
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Learning/get-data.py
Expand Up @@ -10,6 +10,7 @@
import json, time, collections, sys
from mixpanel import Mixpanel
from secrets import MIXPANEL
from datetime import datetime

import functools
import cPickle
Expand Down Expand Up @@ -146,18 +147,29 @@ def line(entry):
data = feedparser.parse(sys.argv[1])
data = cleanup(data)

print MIXPANEL

mx = Mixpanel(MIXPANEL['api_key'], MIXPANEL['api_secret'])

for entry in data.entries:
# print entry.wp_post_date_gmt.split(' ')[0]
# print entry.link
print mx.request(['funnels'],
{'funnel_id': 6517,
'from_date': entry.wp_post_date_gmt.split(' ')[0],
'where': 'url=='+entry.link})
break
try:
date = datetime.strptime(entry.wp_post_date_gmt,
'%Y-%m-%d %H:%M:%S')
except ValueError:
continue

funnel = mx.request(['funnels'],
{'funnel_id': 6517,
'from_date': date.strftime('%Y-%m-%d'),
'where': 'url=='+entry.link})
if 'error' in funnel.keys():
print funnel
merged = {'completion': 0, 'starting_amount': 0, u'steps': 0, u'worst': 0}
for k in funnel['data'].keys():
for kk in funnel['data'][k]['analysis'].keys():
merged[kk] += funnel['data'][k]['analysis'][kk]
merged['steps'] = merged['steps']/len(funnel['data'])
print merged

# print mx.request(['funnels'],
# {'funnel_id': 6517,
Expand Down

0 comments on commit 277b8e8

Please sign in to comment.