Commit 4ee573cf authored by Bastien Durel's avatar Bastien Durel
Browse files

cleanup each time

parent 185afe29
#!/bin/bash #!/bin/bash
if [ -r covid.csv ]; then rm -f covid.csv covid_corrected.csv
date=$(stat -c %y covid.csv)
else
date=""
fi
wget -O covid.csv -cq https://www.data.gouv.fr/fr/datasets/r/63352e38-d353-4b54-bfd1-f1b3ee1cabd7 wget -O covid.csv -cq https://www.data.gouv.fr/fr/datasets/r/63352e38-d353-4b54-bfd1-f1b3ee1cabd7
date_new=$(stat -c %y covid.csv) sed -E 's@([0-9]+)/([0-9]+)/([0-9]+)@\3-\2-\1@' \
if [ "$date" != "$date_new" -o ! -r covid_corrected.csv ]; then < covid.csv | sed 's/\r$//' | \
sed -E 's@([0-9]+)/([0-9]+)/([0-9]+)@\3-\2-\1@' \ grep -v "^;" | \
< covid.csv | sed 's/\r$//' | \ grep "-" > covid_corrected.csv
grep "-" > covid_corrected.csv psql -h postgresql.cloud.data.fr -U bastien \
psql -h postgresql.cloud.data.fr -U bastien \ -c "truncate covid;COPY covid FROM stdin DELIMITER ';' CSV HEADER;" \
-c "truncate covid;COPY covid FROM stdin DELIMITER ';' CSV HEADER;" \ < covid_corrected.csv
< covid_corrected.csv
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment