Created
February 16, 2015 22:22
-
-
Save evansd/bb418a7d610de96edcf5 to your computer and use it in GitHub Desktop.
Experimenting with MOT data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| import json | |
| from collections import defaultdict | |
| if __name__ == '__main__': | |
| data = defaultdict( | |
| lambda: defaultdict( | |
| lambda: defaultdict( | |
| lambda: defaultdict(int)))) | |
| for line in sys.stdin: | |
| row = line.split('|') | |
| try: | |
| year_of_test = int(row[2][:4]) | |
| year_first_used = int(row[13][:4]) | |
| except ValueError: | |
| continue | |
| result = row[5] | |
| make = row[8] | |
| model = row[9] | |
| age = year_of_test - year_first_used | |
| data[make][model][age][result] += 1 | |
| json.dump(data, sys.stdout, indent=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Use zcat so we can work directly on the gzipped data without unzipping it first | |
| zcat test_result_* | ./aggregate_data.py > breakdown.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment