3 A module for loading data from the Harry Potter wikipedia data set
7 from datetime import datetime
9 f = open('hp_wiki.tsv', 'r')
10 reader = csv.DictReader(f, delimiter='\t')
13 for fieldname in reader.fieldnames:
14 columns[fieldname] = []
19 # Convert timestamp from a string to a date:
20 row['timestamp'] = datetime.strptime(row['timestamp'], '%Y-%m-%d %H:%M:%S')
21 # Convert size from a string to an integer:
22 row['size'] = int(row['size'])
25 # Sort these things, so that they give you nice ordered time-series
26 sort_rows = sorted(rows, key=lambda row: row['timestamp'], reverse=False)
30 for fieldname, value in row.items():
31 columns[fieldname].append(value)