2015-04-08 17:28:18 -06:00
|
|
|
#! /usr/bin/awk -f
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
nteams = 0;
|
|
|
|
print "{";
|
|
|
|
print " \"points\": [";
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
ts = $1;
|
|
|
|
hash = $2;
|
|
|
|
cat = $3;
|
|
|
|
points = $4;
|
|
|
|
|
|
|
|
teamno = teams[hash];
|
|
|
|
if (! teamno) {
|
|
|
|
teamno = ++nteams;
|
|
|
|
teams[hash] = teamno;
|
|
|
|
|
|
|
|
getline teamnames[teamno] < ("state/teams/" hash)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NR > 1) {
|
|
|
|
# JSON sucks.
|
|
|
|
print ",";
|
|
|
|
}
|
|
|
|
printf("[%d, \"%d\", \"%s\", %d]", ts, teamno, cat, points);
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
print "";
|
|
|
|
print " ],";
|
|
|
|
print " \"teams\": {";
|
|
|
|
|
2015-04-22 08:31:00 -06:00
|
|
|
for (i = 1; i <= nteams; i += 1) {
|
2015-04-08 17:28:18 -06:00
|
|
|
if (i > 1) {
|
|
|
|
print ",";
|
|
|
|
}
|
|
|
|
printf("\"%d\": \"%s\"", i, teamnames[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
print "";
|
|
|
|
print " }";
|
|
|
|
print "}";
|
2015-04-22 08:31:00 -06:00
|
|
|
}
|