{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from csv import DictReader" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "input_file = open(\"hp_wiki.tsv\", 'r', encoding='utf-8')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "num_edits = 0\n", "num_anon = 0\n", "for row in DictReader(input_file, delimiter=\"\\t\"):\n", " num_edits = num_edits + 1\n", " if row[\"anon\"] == \"True\":\n", " num_anon = num_anon + 1\n", "\n", "prop_anon = num_anon / num_edits" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(f\"total edits: {num_edits}\")\n", "print(f\"anon edits: {num_anon}\")\n", "print(f\"proportion anon: {prop_anon}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }