]> projects.mako.cc - matplotlib-cdsw/blobdiff - load_hp_data.py
Added some challenges to the HP analysis.
[matplotlib-cdsw] / load_hp_data.py
index 85cf142852ba96fd1fa2f937619e4ed30b838f9f..55d497c441a5c0e2260a241fe700115f5231f035 100644 (file)
@@ -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 ordered 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)

Benjamin Mako Hill || Want to submit a patch?