Last active
June 18, 2018 05:32
-
-
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)
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
#!/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