Last active
April 7, 2020 21:12
-
-
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
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
#!/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