Skip to content

Instantly share code, notes, and snippets.

@radames
Last active April 7, 2020 21:12
Show Gist options
  • Save radames/88e751adc0ef23a58a4f347cf5935f80 to your computer and use it in GitHub Desktop.
Save radames/88e751adc0ef23a58a4f347cf5935f80 to your computer and use it in GitHub Desktop.
Shell script to aggregate country level COVID-19 Mobility data from https://github.com/kylemcdonald/covid-mobility-data
#!/bin/zsh
# You can run this on base folder with all csvs
rm -f res/world.tsv;
touch res/world.tsv;
firstfile=`ls -t *.tsv | head -n 1`
col=`echo 'code\t'`
firstline=`ls -t *.tsv | head -n 1 | xargs sed -n '1,1p'`
res=`echo $firstline | sed 's/^/'$col'/'`;
echo $res >> res/world.tsv;
for f in `ls *.tsv`;
do;
lines=`sed -n '2,7p' $f`;
code=`echo $f | cut -d"_" -f2`;
tab=`echo $code'\t'`
res=`echo $lines | sed 's/^/'$tab'/'`;
echo $res >> res/world.tsv;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment