Last active
April 14, 2020 07:18
-
-
Save dotslash/dffa202f005239c109e94e1797436187 to your computer and use it in GitHub Desktop.
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
# Setup | |
# pip install colored tabulate | |
# brew install jq (mac) | |
# sudo apt-get install jq (ubuntu) | |
alias json_tabulate='python -c "from colored import fg, bg, attr; import json; import fileinput; import tabulate; lines=[line for line in fileinput.input() if line.strip()]; dicts=json.loads(\" \".join(lines)); keys = (dicts and dicts[0].keys()) or []; keys = {k:fg(\"yellow\") + attr(\"bold\")+ k + attr(\"reset\") for k in keys}; print(tabulate.tabulate(dicts, headers=keys))"' | |
alias update_covid_ind='curl https://api.covid19india.org/data.json > ~/tmp/covid_ind.json' | |
alias covid_ind_tests='jq ".tested | map({totalpositivecases, totalindividualstested, samplereportedtoday, as_of: .updatetimestamp})" ~/tmp/covid_ind.json | json_tabulate' | |
alias covid_ind_states='jq ".statewise | map({state, confirmed, new: .deltaconfirmed, last_updated: .lastupdatedtime})" ~/tmp/covid_ind.json | json_tabulate' | |
alias covid_ind_daily='jq ".cases_time_series | map({date, dailyconfirmed, totalconfirmed}) | .[-20:]" ~/tmp/covid_ind.json | json_tabulate' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment