Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
simple script to say group e results as they're updated
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