projects
/
harrypotter-wikipedia-cdsw
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
improvements based on a run-through in COM597G
[harrypotter-wikipedia-cdsw]
/
hpwp-trend.py
diff --git
a/hpwp-trend.py
b/hpwp-trend.py
index 939406e5a2b902d586b736a2736e6b39cac3cd28..aaa2b70a0ef3a088fcad40d174571ccf806ff154 100644
(file)
--- a/
hpwp-trend.py
+++ b/
hpwp-trend.py
@@
-1,10
+1,10
@@
from csv import DictReader
# read in the input file and count by day
from csv import DictReader
# read in the input file and count by day
-input_file = open("hp_wiki.
csv", 'r'
)
+input_file = open("hp_wiki.
tsv", 'r', encoding="utf-8"
)
edits_by_day = {}
edits_by_day = {}
-for row in DictReader(input_file):
+for row in DictReader(input_file
, delimiter="\t"
):
day_string = row['timestamp'][0:10]
if day_string in edits_by_day:
day_string = row['timestamp'][0:10]
if day_string in edits_by_day:
@@
-15,13
+15,13
@@
for row in DictReader(input_file):
input_file.close()
# output the counts by day
input_file.close()
# output the counts by day
-output_file = open("hp_edits_by_day.
csv", "w"
)
+output_file = open("hp_edits_by_day.
tsv", "w", encoding='utf-8'
)
# write a header
# write a header
-output_file.write("date
,
edits\n")
+output_file.write("date
\t
edits\n")
# iterate through every day and print out data into the file
# iterate through every day and print out data into the file
-for day_string in edits_by_day:
- output_file.write("
,
".join([day_string, str(edits_by_day[day_string])]) + "\n")
+for day_string in edits_by_day
.keys()
:
+ output_file.write("
\t
".join([day_string, str(edits_by_day[day_string])]) + "\n")
output_file.close()
output_file.close()
Benjamin Mako Hill
||
Want to submit a patch?