Skip to content

Instantly share code, notes, and snippets.

@XertroV
Last active September 10, 2016 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XertroV/bf182b1578b8494a6ccfd1e09644dbf9 to your computer and use it in GitHub Desktop.
Save XertroV/bf182b1578b8494a6ccfd1e09644dbf9 to your computer and use it in GitHub Desktop.
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