X-Git-Url: https://projects.mako.cc/source/matplotlib-cdsw/blobdiff_plain/0a6b1b4db717da540e57c15eb7506d2d8f75da58..7bd9bbbbb11d7585b76e63e354c0c779d5a8c547:/load_hp_data.py diff --git a/load_hp_data.py b/load_hp_data.py index 85cf142..0fe78c5 100644 --- a/load_hp_data.py +++ b/load_hp_data.py @@ -16,8 +16,16 @@ for fieldname in reader.fieldnames: 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 + # Convert timestamp from a string to a date: + row['timestamp'] = datetime.strptime(row['timestamp'], '%Y-%m-%d %H:%M:%S') + # Convert size from a string to an integer: + row['size'] = int(row['size']) + rows.append(row) + +# Sort these things, so that they give you nice time-series +sort_rows = sorted(rows, key=lambda row: row['timestamp'], reverse=False) + +rows = sort_rows +for row in sort_rows: + for fieldname, value in row.items(): + columns[fieldname].append(value)