User:AmaureaUploadBot
Jump to navigation
Jump to search
This bot will periodically update my graphs of opinion poll data for Norwegian elections with new data from PollOfPolls. Examples of such plots (made by User:Amaurea) can be found here [1].
- Operator: Amaurea (talk)
- Tasks: Periodic uploads of updated graphs of opinion polling data
- Operation: Automatic
- When: Daily
- Maximum edit rate: 12/minute (but will only upload/overwrite 10-20 (currently 12) per day
- Language: Python
Source code
[edit]The bot has 3 parts. The first is an overall driver script that fetches the raw data and then calls the plotting and uploading parts:
wget -O tmp/gallup.json http://www.pollofpolls.no/api/gallup.php wget -O storting.csv 'http://www.pollofpolls.no/lastned.csv?tabell=gallupsnitttabell&antall=0&type=riks&int=m&kommuneid=0&start=1950-01-01&slutt=2100-01-01' ./csv2table storting.csv > storting.txt ./json2table gallup.json > gallup.txt gnuplot storting.gpi gnuplot storting_errs.gpi # Make the svgs palatable to wikipedia for i in storting.svg storting_blocks.svg storting_small.svg; do sed 's/ onmouse[^>]*>/>/g' $i > tmp.svg; mv tmp.svg $i; done ./wikipedia_upload
The various conversion and plotting scripts are here: csv2table, json2table, storting.gpi, storting_errs.gpi.
Finally, the actual upload script, which is the only thing that interacts with Wikipedia, is here: wikipedia_upload.
This script is a bit crufty because it grew gradually from a much simpler and less capable one. If I were to do this again I would probably write the whole thing in python.