A new data loader for campaign finance that is totally separate from the front end
This module uses nyt-pyfec
to parse .fec files and dumps the results in a postgres database. It doesn't stray far from the FEC's raw data, but it does mark filings as amended or covered by a periodic filing (and marks newest=False in those cases).
To query valid transactions, include WHERE newest=true
in any queries. If you want totals that are close to itemized totals reported by the FEC, also include where memo_entry=false
- Use python3
- Install postgres
- Create a postgres database
- If using virtualenvwrapper (which is STRONGLY RECOMMENDED):
mkvirutalenv campfin-loader --python $(which python3)
pip install -r requirements.txt
- Add your database credentials as environment varibales
DB_NAME
,DB_HOST
,DB_USER
andDB_PASSWORD
(the latter defaults to None). Recommended: do this in$VIRTUAL_ENV/bin/postactivate
if you're using virtualenvwrapper - Get an FEC API key. (Or submit a pull request to scrape the page!)
- Use the methods in
fec_scrape.py
. The easiest way to scrape local filings right now is to runpython -c 'from fec_scrape import load_recent_filings; load_recent_filings()'
. Commandline interface hopefully coming soon.