#!/usr/bin/python # Minas Gjoka import urllib,re, sys, time, random, datetime, time, signal, urllib2, cookielib, httplib, gzip, glob, os, csv import Gnuplot, Gnuplot.funcutils point_types = [12,3,13,2,5,6,7,1,0,9,10,14] def plotcategdata(data_set,selections,name_mapping): s = 'plot ' for j in range(len(selections)): i = selections[j] categ_name = data_set[i] s = '%s "%s" every 2 using ($1-66):($2/$3) with linespoints pt %d lw 2 title "%s", ' % (s,categ_name,point_types[j],name_mapping[i]) s = s[0:len(s)-2] g = Gnuplot.Gnuplot(debug=0) g('set grid') #g('set logscale x') #g('set logscale y') #g('set key out vert') g('set pointsize 1.5') g('set key on') g('set key top right') g.xlabel('Day') g.ylabel('Average Daily Active users') g('set terminal postscript monochrome enhanced "Arial" 16') g('set output "appcategories.eps"') g('%s' % s) apps = { "Super Wall":"2601240224", "FunWall":"2378983609", "SuperPoke!":"2357179312", "Hug Me(rockyou)":"2345673396", "Will you KISS me?":"6323135851", "Graffiti":"2357293998", "Honesty Box":"2552096927", "Vampires":"2458301688", "Social Profile":"4554458539", "Hug Me(jambul)":"6957991613", "Nicknames":"4071248179", "Zombies":"2341504841", "LOVE ME Secret Lovers HAPPY VALENTINE":"8533348662", "WereWolves":"2721700161", "Slayers":"17801732384", "Advanced Wall":"3118555174", "Send Good Karma":"7198368974", "Sticky Notes":"2384089789", "Nasilim? - How Do I Look?":"18687709560", "Will you KISS me?":"6323135851", "Hugs":"18655296760", "Friend Hug":"5655417519", "Are YOU Interested?":"17091798008", "Zoosk":"6953377468", "Spark":"6280837251", "Flirtable":"5098764373", "Meet New People":"2431056848", "HOT or NOT":"2252801962", "Secret Admirer - CRUSH on ME (PERFECT MATCH)":"7211414796", "Compare HOTNESS":"7769226005", "Kiss Kiss":"7281078353", "Make New Friends":"7241666813", "Human Pets":"2437228683", "We're Related":"5388815661", "Scrabulous":"3052170175", "Friends For Sale!":"7019261521", "Texas HoldEm Poker":"2389801228", "Owned!":"6251039081", "Speed Racing":"5475824764", "MindJolt Games":"5706713477", "(fluff)Friends":"2219808235", "PetrolHead":"5005284316", "Jetman":"4243149646", "Scramble":"6494671374", "Dope Wars":"6657868731", "Blackjack":"5803363687", "Fight Club":"4520048983", "Parking Wars":"31435010008", "Scratch and Win":"5173067945", "WarBook":"2618691293", "Premier Football":"5644329558", "Pet Dragons":"4856649013", "OneTrack":"14015860542", "PuzzleBee":"2356957881", "Plane Crazy":"8409411996", "Triumph":"6058549658", "ATTACK!":"5053052479", "Top Friends":"2425101550", "Compare People":"2433486906", "Likeness":"2405948328", "Likeness UNRATED":"4188419540", "Circle of Friends":"2270425051", "Superlatives":"2372128250", "You're a Hottie":"6921127772", "Who Has The Biggest Brain?":"8827826004", "Compare HOTNESS":"7769226005", "MY SEXY FRIENDS":"8059336893", "Best Friends":"6421213170", "Growing Gifts":"2402094537", "Free Gifts":"2415466380", "Hatching Eggs":"6702295930", "Thinking of You":"11962735836", "Booze Mail":"2360569570", "Winnie the Pooh":"8764366621", "Movies":"2558160538", "iLike":"2413267546", "Mesmo TV":"3642144705", "Bumper Sticker":"2427603417", "(Lil) Green Patch":"7629233915", "Quizzes":"2341007765", "Have You Ever???":"7689809763", "Moods":"3129295789", "My Heroes Ability":"6568019289", "Causes":"2318966938", "Characteristics":"18002817304", "Entourage":"4706620662", "Friend Block":"2610371153", "Big Photo":"2388801017", "Sketch Me":"4260387428", "Mobile":"2915120374", "Who's Online":"5952993979", "Name Analyzer":"10939930426", "Daily Babe":"2464016603", "Fortune Cookie":"2355237624", "Where I've Been":"2603626322", "Cities I've Visited":"2219089314", "Birthday Calendar":"5437153164", "Horoscopes":"2339854854"} #---- casual_communication_initial = [ "Super Wall", "FunWall", "SuperPoke!", "Hug Me(rockyou)", "Will you KISS me?", "Graffiti", "Honesty Box", "Vampires", "Social Profile", "Hug Me(jambul)", "Nicknames", "Zombies", "LOVE ME Secret Lovers HAPPY VALENTINE", "WereWolves", "Slayers", "Advanced Wall", "Send Good Karma", "Sticky Notes", "Nasilim? - How Do I Look?", "Will you KISS me?", "Hugs", "Friend Hug" ] casual_communication_second = [ "Super Wall", "FunWall", "Graffiti", "Honesty Box", "Social Profile", "Nicknames", "LOVE ME Secret Lovers HAPPY VALENTINE", "Advanced Wall", "Send Good Karma", "Sticky Notes", "Nasilim? - How Do I Look?" ] gestures = [ "SuperPoke!", "Hug Me(rockyou)", "Hug Me(jambul)", "Will you KISS me?", "Vampires", "Zombies", "WereWolves", "Slayers", "Hugs", "Friend Hug"] meeting_people = [ "Are YOU Interested?", "Zoosk", "Spark", "Flirtable", "Meet New People", "HOT or NOT", "Secret Admirer - CRUSH on ME (PERFECT MATCH)", "Compare HOTNESS", "Kiss Kiss", "Make New Friends", "Human Pets", "We're Related" ] casual_gaming = [ "Scrabulous", "Friends For Sale!", "Texas HoldEm Poker", "Owned!", "Speed Racing", "MindJolt Games", "(fluff)Friends", "PetrolHead", "Jetman", "Scramble", "Dope Wars", "Blackjack", "Fight Club", "Parking Wars", "Scratch and Win", "WarBook", "Premier Football", "Pet Dragons", "OneTrack", "PuzzleBee", "Plane Crazy", "Triumph", "ATTACK!" ] friend_comparison = [ "Top Friends", "Compare People", "Likeness", "Likeness UNRATED", "Circle of Friends", "Superlatives", "You're a Hottie", "Who Has The Biggest Brain?", "Compare HOTNESS", "MY SEXY FRIENDS", "Best Friends" ] gifting = [ "Growing Gifts", "Free Gifts", "Hatching Eggs", "Thinking of You", "Booze Mail", "Winnie the Pooh" ] rating_recommend = [ "Movies", "iLike", "Mesmo TV" ] self_expression = [ "Bumper Sticker", "(Lil) Green Patch", "Quizzes", "Have You Ever???", "Moods", "My Heroes Ability", "Causes", "Characteristics" ] multimedia = [ "Entourage", "Friend Block", "Big Photo", "Sketch Me"] generic_utility = [ "Mobile", "Who's Online", "Name Analyzer", "Daily Babe", "Fortune Cookie", "Where I've Been", "Cities I've Visited"] news_alerts = [ "Birthday Calendar", "Horoscopes" ] #--- categories = [ casual_communication_second, gestures, meeting_people, casual_gaming, friend_comparison, gifting, self_expression, multimedia, generic_utility, news_alerts, rating_recommend, rating_recommend] categories_names = [ "categ-casual_communication", "categ-gestures", "categ-meeting_people", "categ-casual_gaming", "categ-friend_comparison", "categ-gifting", "categ-self_expression", "categ-multimedia", "categ-generic_utility", "categ-news_alerts", "categ-rating_recommend", "categ-rating_recommend"] for i in range(len(categories)): print "Accumulate statistics for category %s with %d apps" % (categories_names[i], len(categories[i])) allcategory_dau_time = {} allcategory_nofapps_time = {} data_name = categories_names[i] for j in range(0,min(len(categories[i]),100) ) : appname = categories[i][j] appid = apps[appname] print appname, appid filename = 'app-%s' % appid reader = csv.reader(open(filename, "rb")) #skip first two lines reader.next() reader.next() #row[0] = Date #row[1] = Totals #row[2] = DAU for row in reader: allcategory_dau_time[ row[0] ] = allcategory_dau_time.get( row[0] , 0 ) + int(row[2]) allcategory_nofapps_time[ row[0] ] = allcategory_nofapps_time.get( row[0] , 0 ) + 1 pattern = '%Y-%m-%d' day_map_epoch = {} day_map_counter = {} listofdays = allcategory_dau_time.keys() for date in listofdays: epoch = int(time.mktime(time.strptime(date, pattern))) day_map_epoch[ date ] = epoch listofdays.sort( lambda x,y :cmp(day_map_epoch[x] ,day_map_epoch[y]) ) fout = open(data_name, "w") count = 0 for day in listofdays: count = count + 1 if count > 65 and count <= 235: fout.write("%d %d %d\n" %(count,allcategory_dau_time[day], allcategory_nofapps_time[day]) ) categories_mapping = [ "Casual Communication", "Gestures", "Meeting People", "Casual Gaming", "Friend Comparison", "Gifting", "Self Expression", "Multimedia", "Generic Utility", "News Alerts", "Rating Recommend.", "Rating Recommend."] #selections = [0,1,2,3,4,5,6,7] #selections = [0,4,1,6,2,3,5,7] #selections = [4,0,1,6,5,2,3,8] selections = [4,0,10,1,6,5,2,3] # ranked order plotcategdata(categories_names,selections,categories_mapping)