-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabulate-data
executable file
·81 lines (77 loc) · 1.56 KB
/
tabulate-data
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
git log --no-abbrev --oneline --no-decorate | \
while read commit other_stuff; do
[[ $other_stuff =~ ^Update ]] || continue
printf '%s:\t%s\n' commit "$commit" date "$other_stuff"
git cat-file -p "$commit":coronavirus-cases.html 2> /dev/null | \
awk '
/<td>Negative/ || \
/<td>Currently under investigation/ || \
/<td>Confirmed positive/ || \
/<td>Resolved/ || \
/<td>Deceased/ || \
/Total number of patients approved for COVID-19 testing/ {
key = $0
sub(/.*<td>(<strong>)?/, "", key)
sub(/<.*/, "", key)
getline
val = $0
sub(/.*<td>(<b>)?/, "", val)
sub(/<.*/, "", val)
print key ":\t" val
}'
echo '%%'
done | \
awk '
BEGIN {
fmt = "%40s %24s %7d %7d %7d %7d %7d %7d\n"
fmt2 = fmt
gsub(/%7d/, "%7s", fmt2)
gsub(/%/, "%-", fmt2)
printf(fmt2, "Commit", "Date", "Neg.", "Investi.", "Positv", \
"Resolv.", "Dec'"'"'d", "Tst.Ap.")
# These column header/footer names are trash, I am sorry
# about that. Just trying to fit them into 7 characters.
}
function getval( str) {
str = $0
sub(/.*:\t/, "", str)
return str
}
/^commit:/ {
commit = getval()
next
};
/^date:/ {
date = getval()
sub(/^Update as of /, "", date)
next
}
/^Negative:/ {
neg = getval()
next
}
/^Currently under investigation:/ {
inv = getval()
next
}
/^Confirmed positive/ {
pos = getval()
next
}
/^Resolved/ {
res = getval()
next
}
/^Deceased/ {
dec = getval()
next
}
/^Total number/ {
tot = getval()
next
}
/^%%$/ {
printf(fmt, commit, date, neg, inv, pos, res, dec, tot)
}' | \
tac