Skip to content

Instantly share code, notes, and snippets.

@jnoss
Last active June 24, 2017 20:58
Show Gist options
  • Save jnoss/07e4879f8f81daa5dddb0f77c8b7c571 to your computer and use it in GitHub Desktop.
Save jnoss/07e4879f8f81daa5dddb0f77c8b7c571 to your computer and use it in GitHub Desktop.
Forbes FEC downloader

to use Forbes FEC downloader

Source: https://www.forbes.com/sites/jonbruner/2011/02/03/how-to-build-your-own-political-contribution-database

MySQL-python

The MySQLdb their code is looking for is pip installable, name is MySQL-python

patch for new data format

FEC ftp site has a new format since the article was written in 2011, with files in folders for each year; to accomodate this: in downloadAll.py replace line 41 (the one with the urlstr = "ftp..." with these 2 lines:

        longyr = '20'+yr
        urlstr = "ftp://ftp.fec.gov/FEC/%s/%s%s.zip" % (longyr,fileType,yr)

credentials

Need to be updated in several files, where they have conn = MySQLdb.connect(... need to enter in the password you set for your local mysql user

...

Looks like the data format the FEC provides is different now than it was when this article was written, so this will take some re-writing to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment