Start implementing plotting from the Harry Potter wikipedia data-set.
[matplotlib-cdsw] / load_hp_data.py
diff --git a/load_hp_data.py b/load_hp_data.py
new file mode 100644 (file)
index 0000000..85cf142
--- /dev/null
@@ -0,0 +1,23 @@
+""" load_hp_data.py 
+
+A module for loading data from the Harry Potter wikipedia data set
+
+""" 
+import csv
+from datetime import datetime
+
+f = open('hp_wiki.tsv', 'r')
+reader = csv.DictReader(f, delimiter='\t')
+
+columns = {}
+for fieldname in reader.fieldnames:
+       columns[fieldname] = []
+
+
+rows = []
+for row in reader:
+       # Convert timestamp from a string to a date:
+       row['timestamp'] = datetime.strptime(row['timestamp'], '%Y-%m-%d %H:%M:%S')
+       rows.append(row)
+       for fieldname, value in row.items():
+               columns[fieldname].append(value)
\ No newline at end of file

Benjamin Mako Hill || Want to submit a patch?