]> projects.mako.cc - harrypotter-wikipedia-cdsw/blob - hpwp-minor.py
update lecture material to move to notebook
[harrypotter-wikipedia-cdsw] / hpwp-minor.py
1 import encoding_fix
2
3 from csv import DictReader
4
5 input_file = open("hp_wiki.tsv", 'r', encoding="utf-8")
6
7 num_edits = 0
8 num_anon = 0
9 for row in DictReader(input_file, delimiter="\t"):
10     num_edits = num_edits + 1
11     if row["anon"] == "True":
12         num_anon = num_anon + 1
13
14 prop_anon = num_anon / num_edits
15
16 print("total edits: {0}".format(num_edits))
17 print("anon edits: {0}".format(num_anon))
18 print("proportion anon: {0}".format(prop_anon))

Benjamin Mako Hill || Want to submit a patch?