Index: experimental/chrome_speed_metrics/scripts/ct_csv_to_traces.py |
diff --git a/experimental/chrome_speed_metrics/scripts/ct_csv_to_traces.py b/experimental/chrome_speed_metrics/scripts/ct_csv_to_traces.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28b9feab67c296f2c40dec28dd920668e076b4bf |
--- /dev/null |
+++ b/experimental/chrome_speed_metrics/scripts/ct_csv_to_traces.py |
@@ -0,0 +1,32 @@ |
+# Copyright 2016 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Extracts the urls to trace files from a Cluster Telemetry csv output.""" |
+ |
+import csv |
+import sys |
+ |
+def CsvToTraces(infile, outfile): |
+ traces = [] |
+ with open(infile) as inf: |
+ results = csv.DictReader(inf) |
+ for r in results: |
+ for t in r['trace'].split(','): |
+ traces.append(t) |
+ |
+ with open(outfile, 'w') as outf: |
+ for trace in traces: |
+ outf.write(trace + '\n') |
+ |
+def main(): |
+ if len(sys.argv) < 3: |
+ print "Usage: {0} <input-file> <output-file>".format(sys.argv[0]) |
+ return |
+ |
+ input_filename = sys.argv[1] |
+ output_filename = sys.argv[2] |
+ CsvToTraces(input_filename, output_filename) |
+ |
+if __name__ == "__main__": |
+ main() |