updated code to handle printing on windows
[harrypotter-wikipedia-cdsw] / hpwp-minor.py
index 4e173f2daa4db6aaeffebed47e9e3ff99181ee52..79135a1c28049cd95e021fb02526f3f60fc370ef 100644 (file)
@@ -1,16 +1,18 @@
+import encoding_fix
+
 from csv import DictReader
 
 from csv import DictReader
 
-input_file = open("hp_wiki.csv", 'r')
+input_file = open("hp_wiki.tsv", 'r', encoding="utf-8")
 
 num_edits = 0
 num_anon = 0
 
 num_edits = 0
 num_anon = 0
-for row in DictReader(input_file):
+for row in DictReader(input_file, delimiter="\t"):
     num_edits = num_edits + 1
     num_edits = num_edits + 1
-    if row["anon"] == "False":
+    if row["anon"] == "True":
         num_anon = num_anon + 1
 
 prop_anon = num_anon / num_edits
 
         num_anon = num_anon + 1
 
 prop_anon = num_anon / num_edits
 
-print("total edits: %s" % num_edits)
-print("anon edits: %s" % num_anon)
-print("proportion anon: %s" % prop_anon)
+print("total edits: {0}".format(num_edits))
+print("anon edits: {0}".format(num_anon))
+print("proportion anon: {0}".format(prop_anon))

Benjamin Mako Hill || Want to submit a patch?