π‘ 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.csva é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
COPYstatement - Prepare some ready to use reporting views
- Dump these views as
csvfiles - 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 and Python library that draws basic graphs in the terminal.
Graph types supported:
- Bar Graphs
- Color charts
- Multi-variable
- Stacked charts
- Histograms
- Horizontal or Vertical
- Calendar heatmaps
- Emoji!
Quick Start
Command Line Usage
$ 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
Python Module Usage
from termgraph import Data, Args, BarChart
# Create data
data = Data([[10], [25], [50], [40]], ["Q1", "Q2", "Q3", "Q4"])
# Configure chart options
args = Args(
title="Quarterly Sales",
width=50,
format="{:.0f}",
suffix="K"
)
# Create and display chart
chart = BarChart(data, args)
chart.draw()
Output:
# Quarterly Sales
Q1:β¦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)