- Have postgreSQL 9.x installed locally
- Python 2.7.* && virtualenv && pip installed
-
Create a virtualenv
$ virtualenv .venv
-
Activate the created virtualenv
$ source .venv/bin/activate
-
Install dependencies
$ pip install -r requirements.txt
-
Create an empty postgres DB for results storage
$ createdb db_name
-
Create DATABASE_URL environment variable to connect to the DB created in the previous step or change the default value inside default_settings.py
-
Run the script to process and load the DB tables
$ python scripts/process_data_psql.py
-
We have used postgres as the DB because our final destination was the cartodb postgis DB and also because of the magic behind postgres window functions that we have used to create the margin of victory of a candidate over the next one in a given polling station directly on SQL.
-
After our first publication we have detected that there were some polling stations with the "same" name and location but different ids so we ended up generating a common id for those as an auxiliary CSV 'data/maestras/relaciones.csv'