Issues with downloading Updated state legislators/representatives

Hi everyone,

I have a python script set up to bulk download select states data. Unfortunately, when I ran the script today, the last updated field is still displaying dates from 2018, and the representatives are wrong (NC, WA, etc).

Has anyone else run across this? How do I download current representatives by state? My script uses an API code, does that need to be updated on a yearly basis?


Where does your script go for the data? which legislators are you looking at? Many might not have been updated in some time if there’s no new info on them, but you should be seeing new legislators in most cases (there are some special elections, resignations that are perhaps missing and we can correct as needed)

The script downloads from pyopenstates. I’m looking at ~ 21 states, and there’s a number of new representatives, that it’s not capturing any changes since November of 2018.

here’s a snippet of the script. I removed the api key:

import pyopenstates as pos
import zipfile
import pandas as pd

path = ‘//data’
add_data_path = path + r’/AdditionalData’

downloads data from openstates API

def download_zip(state_abb):
with open(add_data_path + ‘/{}’.format(state_abb.lower()), ‘wb’) as zip_file:
print(‘Creating file {}’.format(state_abb))
pos.download_bulk_data(state_abb, zip_file, ‘csv’)

unzips folders

def extract_all(state_abb):
with zipfile.ZipFile(add_data_path + r’{}’.format(state_abb), ‘r’) as zip_ref:

splits data up by upper and lower chambers

def split_chambers(state_abbreviation):
df = pd.read_csv(add_data_path + ‘{}legislators.csv’.format(state_abbreviation.lower()))
lower = df[( is True) | (df.chamber == ‘lower’)]
upper = df[( is True) | (df.chamber == ‘upper’)]
lower.to_csv(add_data_path + r’\lower
{}legislators.csv’.format(state_abbreviation.lower()), index=False)
upper.to_csv(add_data_path + r’\upper
{}_legislators.csv’.format(state_abbreviation.lower()), index=False)
print(‘File split into upper and lower chambers’)

download data for each state

for state in focus_states:

unzip folder for each state

for state in focus_states:
    print('Extracting files from {}'.format(state))
print("Zip files loaded and extracted.")

split chambers for each state

for state in focus_states:

Those data dumps are from 2018 and have been marked as legacy info for a while. has updated data on where you can get bulk data, it’ll probably be easiest to parse the YAML files for now.

So, to clarify, I can’t script a download pull of states anymore? and I can’t use python, but YAML?

Is there a code to bulk download in YAML? I’m not familiar with it, and I didn’t see anything in documentation on how to go about doing a pull of multiple states.

YAML is a format, like CSV. You can use Python to process it.

I’ll get in touch to try to help sort through the issue.