Last active
September 10, 2016 10:35
-
-
Save XertroV/bf182b1578b8494a6ccfd1e09644dbf9 to your computer and use it in GitHub Desktop.
simple script to say group e results as they're updated
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
MAXSOFAR='0'; | |
GROUPEMAX='0' | |
while [ 1 ]; do | |
echo 'running'; | |
CSV=$(curl -s http://votensw.info/data/byron-shire-council/first_preference_councillor.csv) | |
RESULTS=$(echo "$CSV" | tail -n 3 | head -n 1 | cut -d ',' -f 21 | tr -d $'\n' | tr -d $'\r'); | |
GROUPETOTAL=$(echo "$CSV" | tail -n 25 | head -n 1 | cut -d ',' -f 21 | tr -d $'\n' | tr -d $'\r'); | |
JIMMY=$(echo "$CSV" | tail -n 24 | head -n 1 | cut -d ',' -f 21 | tr -d $'\n' | tr -d $'\r') | |
echo "Got Results $RESULTS... Group E: $GROUPETOTAL... Jimmy: $JIMMY" | |
if [[ "$RESULTS" -eq "$MAXSOFAR" ]] ; then | |
echo 'no results' ; | |
# say 'no new results' # debug only | |
else | |
echo 'results updated'; | |
OLDMAX=$MAXSOFAR | |
MAXSOFAR=$RESULTS | |
OLDGROUPE=$GROUPEMAX | |
GROUPEMAX=$GROUPETOTAL | |
GROUPEPROP=$(echo "scale=2; 100.0*($GROUPEMAX+$JIMMY)/$MAXSOFAR" | bc) | |
echo "Proporiton $GROUPEPROP" | |
say "results updated, old number of total votes $OLDMAX, new number of total votes $MAXSOFAR, old number of Group E votes $OLDGROUPE, new number of Group E votes $GROUPEMAX, Jimmy's proportion of all votes is $GROUPEPROP percent"; | |
fi; | |
sleep 10 | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment