π‘ Open Data and charting in terminal
As a big fan of both Open Data, PostgreSQL, terminal tricks and data analysis, I wondered what kind of story I could tell on these topics.
Since one year now I feed an Open Data repo with COVID-19 from New-Caledonia :
adriens / covid19-action-plan-nc
Projet de gestion de mes tΓ’ches liΓ©es aux actions autour de la crise saniatire du COVD-19 en Nouvelle-CalΓ©donie
covid19-action-plan-nc
Projet de gestion de mes tΓ’ches liΓ©es aux actions autour de la crise sanitaire du COVID-19 en Nouvelle-CalΓ©donie
β οΈ Convention sur les donnΓ©es
Depuis le mercredi 08/09/2021, cf #64, les chiffres suivants ne sont plus communiquΓ©s :
- nb. de personnes en quatorzaine
- nb. de tests quotidiens
En conséquence, et afin de garantir l'intégralité du modèle de données :
- Lorsqu'un champ n'a pas la donnΓ© numΓ©rique : remplir avec
-1
- Un nouveau fichier simplifiΓ©
covid19-nc-cas-actifs_deces.csv
a été créé et sera maintenu avec moins de colonnes : y sont consignés les cas confirmés, le nb. de décès, le nb. de premières et secondes injections
RΓ©alisations
To "celebrate" this full year of daily datas, I decided to implement something cool around it and thought about the following scenario :
π The plan
- Git clone the Open Data COVID cases I feed everyday
- Load the csv data in the PostgreSQL table with the
COPY
statement - Prepare some ready to use reporting views
- Dump these views as
csv
files - Produce charts from the command line, for the command line with the help of a great and cool tool called
termgraph
:
Termgraph
A command-line tool that draws basic graphs in the terminal, written in Python.
Graph types supported:
- Bar Graphs
- Color charts
- Multi-variable
- Stacked charts
- Histograms
- Horizontal or Vertical
- Emoji!
Examples
termgraph data/ex1.dat
# Reading data from data/ex1.dat
2007: βββββββββββββββββ 183.32
2008: ββββββββββββββββββββββ 231.23
2009: β 16.43
2010: ββββ 50.21
2011: ββββββββββββββββββββββββββββββββββββββββββββββββββ 508.97
2012: ββββββββββββββββββββ 212.05
2014: β 1.00
An example using emoji as custom tick:
termgraph data/ex1.dat --custom-tick "π" --width 20 --title "Running Data"
# Running Data
2007: πππππππ 183.32
2008: πππππππππ 231.23
2009: 16.43
2010: π 50.21
2011: ππππππππππππππππππππ 508.97
2012: ππππππππ 212.05
2014: 1.00
An example using stdin and emoji:
echo "Label,3,9,1" | termgraph --custom-tick "π" --no-label
πππ 3.00
πππππππππ 9.00
π 1.00
Most results can be copied and pasted wherever you like, since they use standard block characters. However the color charts will not show, since they use terminal escape codes for color. A couple images toβ¦
Also, to make it available even for non technical people.
I decided to implement it on Katacoda, so everyone can enjoy it from any web browser and look like a kind of hacker
π
π¦ Demo
Top comments (0)