DEV Community

Cover image for 📈 Fetch and use French COVID-19 dataset
Rémy F.
Rémy F.

Posted on

📈 Fetch and use French COVID-19 dataset

The French government has published an opensource GIS website to keep an eye on the current epidemic growth.

They also publish the raw dataset but it's a mess to deal with, so let's just scrap the hell of the homepage.

BASE=https://dashboard.covid19.data.gouv.fr
FILE=$(curl -s $BASE | grep -Po '/_next/static/[^/]+?/pages/index.js' | head -n1)
JSON=$(curl -s $BASE/$FILE | grep -Po "JSON.parse\('\[.*?\]" | cut -c13- | sed 's/\\.//g')
Enter fullscreen mode Exit fullscreen mode

You can now plot your 1-month worth of data using your favorite language or spreadsheet.

Paris data as CSV using jq:

echo "$JSON" | jq -r '.[] | select(.nom=="Paris") | [.date,.deces,.reanimation,.hospitalises,.gueris] |@csv'
Enter fullscreen mode Exit fullscreen mode

Or if your a pipe junky, this bad boy will show you a New/Total logarithmic representation as shown in this video :

echo "$JSON" | node -e "
JSON.parse(require('fs').readFileSync('/dev/stdin').toString())
.filter(d=>d.nom=='France')
.map((d,i,a)=>({...d,sum:a.slice(0,i).reduce((a,c)=>a+(c.hospitalises||0),0)}))
.map((d,i,a)=>[d.sum,d.hospitalises-(a[i-1]||{}).hospitalises||0])
.forEach(l=>console.log(l.join(' ')))
" | graph -T png -lx -ly -X 'Total cases' -Y 'New cases variation' | display
Enter fullscreen mode Exit fullscreen mode

Here is the ouput for the whole country

France

Here is the ouput for the Paris region

Paris

Top comments (1)

Collapse
 
andrewrothman profile image
Andrew Rothman

Really cool simple project.

I find "jq" really useful at times. That "graph" tool looks is awesome too. Is it this one?