Hey There.

This is a quickie update. It is Election Day for the Local Government Elections 2011 and results are just beginning to come in.

Real-time results are hard to come by, there is a twitter hashtag to follow namely #LGEResults, but that makes it hard to get an overview of what is going on, which party is in the overall lead.

Lucky for us the IEC has a results page at http://elections.org.za where you can search for the results you want to see and then download either a PDF or Excel spreadsheet to view the results. If you are not interested in the technical aspect of how I parsed the information from the IEC spreadsheet you can view the results HERE: http://g33q.co.za/parties

(Bear in mind that I am not affiliated with the IEC, and with none of the parties – I am just a computer guy who voted and want to see the election results)

The spreadsheet I use for input seems to be updated every 10 or 20 minutes at this stage.

If you want to find out how I actually did the scripting, read on:

It is a bit of a pain, so I wrote a bash script to automatically download the spreadsheet (the URL does not change between updates :-)) and then parse the information. You will need to install the package xls2csv that is relevant to your Linux distribution.

BEHOLD:

#!/bin/bash -x
rm National*
wget http://www.elections.org.za/content/LGEPublicReports/197/Detailed%20Results/National.xls
xls2csv National.xls > parties
awk -F"\"" '{ print $2 $7 $6}' parties | grep -f input > results

Predictably the output is ugly, but it at least gives me some information that I want.

Have fun playing with this one. I use: while sleep 5m; do ./scriptname; done to run it every five minutes, and in the script above I added a simple scp command to upload it to my server where you can view the results at http://g33q.co.za/parties if you want.

Cheers for now!

No related posts.