52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
"""
|
|
fname = 'cache/teacherdata/activity/G00101483.json'
|
|
import json
|
|
import codecs
|
|
from collections import defaultdict as ddict
|
|
from dateutil.parser import parse as parse_dt
|
|
allact = json.loads( codecs.open(fname,'r','utf-8').read() )
|
|
|
|
|
|
unique_urls = set(funcy.pluck('url',allact))
|
|
date_hits = sorted(funcy.pluck('updated_at',allact))
|
|
|
|
|
|
date_hits = list(map(parse_dt, date_hits))
|
|
|
|
dontcare = open('cache/urls_i_dont_care.txt','r').readlines()
|
|
|
|
dd = ddict(int)
|
|
for k in allact: dd[ k['url'] ] += 1
|
|
|
|
dits = ddict(int)
|
|
for j in
|
|
|
|
urls_by_freq = [ (k, v) for k, v in sorted(ddd.items(), key=lambda item: item[1],reverse=True)]
|
|
top_five = [ (k, v) for k, v in sorted(ddd.items(), key=lambda item: item[1],reverse=True)][:5]
|
|
|
|
"""
|
|
|
|
import csv
|
|
|
|
ilearn_version = csv.reader(open('cache\teacherdata\staff_main_table.csv','r').read())
|
|
|
|
|
|
|
|
old_dir = csv.reader(open('cache/personnel2020_04_12.csv'), delimiter=',')
|
|
dept1_crxn = {r[0]:r[1] for r in csv.reader(open('cache/dir_corrections.csv'), delimiter=',') }
|
|
dept2_crxn = {r[0]:r[2] for r in csv.reader(open('cache/dir_corrections.csv'), delimiter=',') }
|
|
title_crxn = {r[0]:r[3] for r in csv.reader(open('cache/dir_corrections.csv'), delimiter=',') }
|
|
|
|
newfile = open('cache/dir_new.txt','w')
|
|
|
|
depts = []
|
|
for r in old_dir:
|
|
old_dept = r[2]
|
|
if old_dept in dept1_crxn:
|
|
new_one = dept1_crxn[old_dept]
|
|
if dept2_crxn[old_dept]: new_one += '/' + dept2_crxn[old_dept]
|
|
if title_crxn[old_dept]: new_one += '/' + title_crxn[old_dept]
|
|
r[2] = new_one
|
|
newfile.write('\t'.join(r) + '\n')
|
|
|
|
|