:

# Unix shell script for counting votes from raw html files.
# To be used after first running "grabridings".
# By Jeffrey S. Rosenthal
# See: http://probability.ca/ontario2018/

set -e

for i in `cat ridinglist`
do

  echo -n "$i\t" | sed "s/\.html//"
  while read -r party
  do
    theval=`grep -A 1 "$party" rawdata/$i \
      | head -2 \
      | tail -1 \
      | tr -dc '0-9'`
    # echo "votes=$theval"
    echo -n "$theval\t"
  done < partylist
  echo ""

done

