for row in reader: videoNames[row[0]] = row[ 1] #cannot remember how this line works exactly print "Determing valid usernames..." #make usernames into a set usernames = Set() with open("Names for SPOC.csv", "rb") as f: reader = csv.reader(f) for row in reader: usernames.add(row[3]) print "Putting videos with usernames..." #add usernames and video ids associated with "play_video" to data data = {} for line in liblytics.read_log_file("tracking_700x_UMass__Fall_2013.log.gz"): if line["event_type"] == "play_video": username = line["username"] if (username != ""): if username not in data: data[username] = Set() event = line["event"] if not isinstance(event, dict): try: event = eval(event) except (NameError): event = event.replace("null", "0") event = eval(event) data[username].add(event["id"]) print "Determining who watched what..."
usernames.add(row[1]) data={} #first dict with username (key) : second dict (value) def parseEventText(eventLine): line = eventLine.replace("{","") line = line.replace("}","") units = line.split(",") result = {} for unit in units: pieces = unit.split(":") result[pieces[0].replace('"',"")] = pieces[1].replace('"',"") return result for line in liblytics.read_log_file("umass_boston-edge-events-ALL.log.gz"): #Reads line in log file if (line["event_type"] == "play_video"): # Grabs only play_videos username=line["username"] t = time.strptime(line['time'].split('+')[0], "%Y-%m-%dT%H:%M:%S.%f") times = time.mktime(t) #first loop creates first dict if username != "": videoName = parseEventText(line["event"])["id"] if username not in data: data[username] = {} usersDict = data[username] #creates third dict with playCount and Times (keys) and their values if videoName not in usersDict: #second loop creates third dict videoDict = {} videoDict["Times"] = [] videoDict["Playcount"] = 1
for row in reader: usernames.add(row[3]) data={} #first dict with username (key) : second dict (value) def parseEventText(eventLine): line = eventLine.replace("{","") line = line.replace("}","") units = line.split(",") result = {} for unit in units: pieces = unit.split(":") result[pieces[0].replace('"',"")] = pieces[1].replace('"',"") return result for line in liblytics.read_log_file("tracking_700x_UMass__Fall_2013.log.gz"): #Reads line in log file if (line["event_type"] == "play_video"): # Grabs only play_videos username=line["username"] t = time.strptime(line['time'].split('+')[0], "%Y-%m-%dT%H:%M:%S.%f") times = time.mktime(t) #first loop creates first dict if username != "": videoName = parseEventText(line["event"])["id"] if videoName in dueDates and times > dueDates[videoName]: if username not in data: data[username] = {} usersDict = data[username] #creates third dict with playCount and Times (import liblytics import csv import time from sets import Set
print "Goal: Finding Seekers" import csv from sets import Set import liblytics print "Translating video names..." #read in video list with nice names videoNames = {} with open("Video Names F14 2.csv", "rU") as f: reader = csv.reader(f) for row in reader: videoNames[row[0]] = row[1] #cannot remember how this line works exactly print "Determing valid usernames..." #make usernames into a set usernames = Set() with open("SPOC Grades Edited.csv", "rb") as f: reader = csv.reader(f) for row in reader: usernames.add(row[1]) print "Putting videos with usernames..." #add usernames and video ids associated with "play_video" to data data = {} for line in liblytics.read_log_file("umass_boston-edge-events-ALL.gz"): if line["event_type"] == "seek_video": username = line["username"] if (username != ""): if username not in data:
data = {} #first dict with username (key) : second dict (value) def parseEventText(eventLine): line = eventLine.replace("{", "") line = line.replace("}", "") units = line.split(",") result = {} for unit in units: pieces = unit.split(":") result[pieces[0].replace('"', "")] = pieces[1].replace('"', "") return result for line in liblytics.read_log_file( "umass_boston-edge-events-ALL.log.gz"): #Reads line in log file if (line["event_type"] == "play_video"): # Grabs only play_videos username = line["username"] t = time.strptime(line['time'].split('+')[0], "%Y-%m-%dT%H:%M:%S.%f") times = time.mktime(t) #first loop creates first dict if username != "": videoName = parseEventText(line["event"])["id"] if username not in data: data[username] = {} usersDict = data[username] #creates third dict with playCount and Times (keys) and their values if videoName not in usersDict: #second loop creates third dict videoDict = {} videoDict["Times"] = [] videoDict["Playcount"] = 1
print "Goal: Finding Seekers" import csv from sets import Set import liblytics print "Translating video names..." #read in video list with nice names videoNames = {} with open("Video Names F14 2.csv", "rU") as f: reader = csv.reader(f) for row in reader: videoNames[row[0]] = row[ 1] #cannot remember how this line works exactly print "Determing valid usernames..." #make usernames into a set usernames = Set() with open("SPOC Grades Edited.csv", "rb") as f: reader = csv.reader(f) for row in reader: usernames.add(row[1]) print "Putting videos with usernames..." #add usernames and video ids associated with "play_video" to data data = {} for line in liblytics.read_log_file("umass_boston-edge-events-ALL.gz"): if line["event_type"] == "seek_video": username = line["username"] if (username != ""): if username not in data: data[username] = Set() event = line["event"] if not isinstance(event, dict):