Exploring the Sunlight Foundation's Congress Legislators Spreadsheet (DRAFT)

Parsing a CSV file with csv.DictReader
This assignment is due on Wednesday, February 17
6 exercises
3.0 possible points
Create a subfolder named 0014-sunlight-congress-csv inside your compciv-2016/exercises folder.

Summary

Hello

Table of contents

The Checklist

In your compciv-2016 Git repository create a subfolder and name it:

     exercises/0014-sunlight-congress-csv

The folder structure will look like this (not including any subfolders such as `tempdata/`:

        compciv-2016
        └── exercises
            └── 0014-sunlight-congress-csv
               ├── a.py
               ├── b.py
               ├── c.py
               ├── d.py
               ├── e.py
               ├── f.py
    
a.py 0.5 points Download the Sunlight Foundation's CSV of Congress legislators
b.py 0.5 points TK
c.py 0.5 points TK
d.py 0.5 points TK
e.py 0.5 points TK
f.py 0.5 points TK

Background information

The file can be found here: http://stash.compciv.org/congress/2016-01/sunlight-legislators.csv

a. Download the spreadsheet, count how many lines b. Print the number of Republicans, Democrats, and Independents ('set') c. Print the names of the 5 oldest and the 5 youngest legislators d. Print the number of men and women who are active legislators e. Count up the men and women, by party, by chamber f. List all states that do not have at least one woman legislator right now.

The Exercises

0014-sunlight-congress-csv/a.py » Download the Sunlight Foundation's CSV of Congress legislators

0014-sunlight-congress-csv/a.py
Download the Sunlight Foundation's CSV of Congress legislators
0.5 points

The file can be found here:

http://stash.compciv.org/congress/2016-01/sunlight-legislators.csv

Expectations

When you run a.py from the command-line:

0014-sunlight-congress-csv $ python a.py
  • The program's output to screen should be:
    There are 898 lines in tempdata/sunlight-legislators.csv

0014-sunlight-congress-csv/b.py » TK

0014-sunlight-congress-csv/b.py
TK
0.5 points

TK

Expectations

When you run b.py from the command-line:

0014-sunlight-congress-csv $ python b.py
  • The program's output to screen should be:
    TK
    

0014-sunlight-congress-csv/c.py » TK

0014-sunlight-congress-csv/c.py
TK
0.5 points

TK

Expectations

When you run c.py from the command-line:

0014-sunlight-congress-csv $ python c.py
  • The program's output to screen should be:
    TK
    

0014-sunlight-congress-csv/d.py » TK

0014-sunlight-congress-csv/d.py
TK
0.5 points

TK

Expectations

When you run d.py from the command-line:

0014-sunlight-congress-csv $ python d.py
  • The program's output to screen should be:
    TK
    

0014-sunlight-congress-csv/e.py » TK

0014-sunlight-congress-csv/e.py
TK
0.5 points

TK

Expectations

When you run e.py from the command-line:

0014-sunlight-congress-csv $ python e.py
  • The program's output to screen should be:
    TK
    

0014-sunlight-congress-csv/f.py » TK

0014-sunlight-congress-csv/f.py
TK
0.5 points

TK

Expectations

When you run f.py from the command-line:

0014-sunlight-congress-csv $ python f.py
  • The program's output to screen should be:
    TK
    

References and Related Readings

Congress API - Legislator spreadsheet
A CSV of basic legislator information, including names, positions, biographical details, contact information, social media accounts, and identifiers for various public databases. It contains current information only - it does not include a legislator’s history of changes to name, party, chamber, etc.
Congress API Legislators Endpoint