-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.sh
executable file
·32 lines (29 loc) · 1.11 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
git pull https://${GITHUB_PERSONAL_TOKEN}@github.com/openstate/amsterdam-subsidies.git master
rm -f message.txt
touch message.txt
wget -q -O tmp-subsidies2.csv "https://api.data.amsterdam.nl/dcatd/datasets/yvlbMxqPKn1ULw/purls/1"
if [ `file tmp-subsidies2.csv |grep Zip |wc -l` -gt 0 ];
then
mv tmp-subsidies2.csv tmp-subsidies2.zip
unzip -p tmp-subsidies2.zip >tmp-subsidies.csv
else
cp tmp-subsidies2.csv tmp-subsidies.csv
fi
csvformat -d ',' -D ',' -e iso-8859-1 tmp-subsidies.csv >tmp-subsidies2.csv
csvcut -c 1-12 tmp-subsidies2.csv >tmp-subsidies3.csv
sed '1s/^\xEF\xBB\xBF//;${/^$/d;}' tmp-subsidies3.csv >"subsidies.csv"
csv-diff subsidies-old.csv subsidies.csv --key=Id >>message.txt
cp -f subsidies.csv subsidies-old.csv
git add subsidies.csv
git config --global user.email "[email protected]"
git config --global user.name "Subsidiebot Amsterdam"
COMMSG=`cat message.txt`
if [ -z "$COMMSG" ];
then
echo "Nothing changed."
else
git commit -F message.txt && \
git push -q https://${GITHUB_PERSONAL_TOKEN}@github.com/openstate/amsterdam-subsidies.git master \
|| true
fi