Skip to content

Instantly share code, notes, and snippets.

@robla
Last active June 18, 2018 05:32
Show Gist options
  • Save robla/cfd95a8d8475c8b4b8c54a34cd56a3ea to your computer and use it in GitHub Desktop.
Save robla/cfd95a8d8475c8b4b8c54a34cd56a3ea to your computer and use it in GitHub Desktop.
Very crude tool to tally the output of sfballotparse.py for 2018 in particular (with hardcoded last names for the top 3 candidates this past election)
#!/bin/bash
# Very crude tool to tally the output of sfballotparse.py for 2018 in particular
# (with hardcoded last names for the top 3 candidates this past election)
votefile=${1}
if [ ! -f "${votefile}" ]; then
echo "${votefile} not found"
exit
fi
for cand1 in BREED KIM LENO; do
for cand2 in BREED KIM LENO; do
if [ "${cand1}" != "${cand2}" ]; then
# echo $cand1 over $cand2
over=$(grep ${cand1}.*${cand2} $votefile | wc -l | awk '{print $1}')
instead=$(grep ${cand1} ${votefile} | grep -v ${cand2} | wc -l | awk '{print $1}')
echo "$(expr $over + $instead) voters prefer $cand1 over $cand2"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment