5 "execution_count": null,
9 "from csv import DictReader"
14 "execution_count": null,
18 "# read in the input file and count by day\n",
19 "input_file = open(\"hp_wiki.tsv\", 'r', encoding=\"utf-8\")"
24 "execution_count": null,
28 "edits_by_day = {}\n",
29 "for row in DictReader(input_file, delimiter=\"\\t\"):\n",
30 " day_string = row['timestamp'][0:10]\n",
32 " if day_string in edits_by_day:\n",
33 " edits_by_day[day_string] = edits_by_day[day_string] + 1\n",
35 " edits_by_day[day_string] = 1"
40 "execution_count": null,
49 "execution_count": null,
53 "# output the counts by day\n",
54 "output_file = open(\"hp_edits_by_day.tsv\", \"w\", encoding='utf-8')\n",
57 "print(\"date\\tedits\", file=output_file)"
62 "execution_count": null,
66 "# iterate through every day and print out data into the file\n",
67 "for day_string in edits_by_day.keys():\n",
68 " print(\"\\t\".join([day_string, str(edits_by_day[day_string])]), file=output_file)\n",
75 "execution_count": null,
83 "display_name": "Python 3",
92 "file_extension": ".py",
93 "mimetype": "text/x-python",
95 "nbconvert_exporter": "python",
96 "pygments_lexer": "ipython3",