Skip to main content

Python client for RealClearPolitics.

Project description

Build Status codecov

Python client for RealClearPolitics.


pip install realclearpolitics


usage: rcp [-h] [--output [OUTPUT]] [--generate-table] url [url ...]

positional arguments:
  url                The url of the polling data.

optional arguments:
  -h, --help         show this help message and exit
  --output [OUTPUT]  The output file name.
  --generate-table   Pass this argument to generate a table.


Get the US general election results.

rcp --output general.csv

Download multiple polls.

rcp \
> \

API Usage

Search for Fox News poll numbers for Trump:

from rcp import get_polls, get_poll_data
from pprint import pprint

polls = get_polls(candidate="Trump", pollster="Fox")

for poll in polls:
    td = get_poll_data(poll['url'])

The will return a dictionary structured like this:

        'data': [{'Biden (D)': '49.6',
                'Date': '3/27 - 7/9',
                'MoE': '--',
                'Poll': 'RCP Average',
                'Sample': '--',
                'Spread': 'Biden +8.5',
                'Trump (R)': '41.1'},
    'poll': ''


Write a poll to CSV:

from rcp import get_polls, get_poll_data, to_csv

polls = get_polls(candidate="Biden")[0]
data = get_poll_data(polls['url'], csv_output=True)
to_csv('output.csv', data)

Create table:

from rcp import get_poll_data
from prettytable import PrettyTable

x = PrettyTable()

td = get_poll_data(

x.field_names = list(td[0]["data"][0].keys())
x.align = "l"

for row in td[0]["data"]:


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for realclearpolitics, version 1.4.0
Filename, size File type Python version Upload date Hashes
Filename, size realclearpolitics-1.4.0-py2.py3-none-any.whl (4.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size realclearpolitics-1.4.0.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page