-
-
Save xdhmoore/2251e24346dc93b25d39 to your computer and use it in GitHub Desktop.
Manipulate GitHub Archive data downloaded from Google BigQuery in order to make a graph in Excel.
Transforms CSV of form: [watchers, repository_name, parsed_date] to form: [date, backbone count, angular.js count, ember.js count, knockout count]
This file contains 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
import csv | |
names = sorted(['backbone', 'angular.js', 'ember.js', 'knockout']) | |
with open('in.csv') as csvfile: | |
reader = csv.reader(csvfile, delimiter=',') | |
dates = {} | |
next(reader) | |
for row in reader: | |
count = row[0] | |
framework = row[1] | |
date = row[2] | |
if date not in dates: | |
dates[date] = {} | |
dates[date][framework] = count | |
header = 'date' | |
for n in names: | |
header += ',' + n + '' | |
header += '' | |
print(header) | |
for date in sorted(dates): | |
for n in names: | |
if n not in dates[date]: | |
dates[date][n] = '' | |
line = '' + date + '' | |
for name in names: | |
line += ',' + dates[date][name] + '' | |
print(line) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment