Campaign Contributions Example

med2016.txt dataset

$ python contributions.py
Welcome to contributions.py v1.0

In this program, you can search for campaign contribution
information by zip code, city, or state.

There are 18377 total contribution entries.

Please choose from the following menu.
  (1) search by zip code
  (2) search by city
  (3) search by state
  (4) quit the program

What would you like to do? 1
Enter a 5-digit ZIP code: DE
zip codes must be 5 digits.
Enter a 5-digit ZIP code: 10010

Contribution information for NEW YORK, NY 10010
  Clinton:  111 contributions totalling  $187670
  Sanders:   23 contributions totalling   $13697
     Cruz:    2 contributions totalling     $750
    Trump:    1 contributions totalling     $500
   Kasich:    1 contributions totalling     $400

Please choose from the following menu.
  (1) search by zip code
  (2) search by city
  (3) search by state
  (4) quit the program

What would you like to do? 2

searching by city...

Enter a city: 19081
I'm sorry, I can't find anything for that city...

Please choose from the following menu.
  (1) search by zip code
  (2) search by city
  (3) search by state
  (4) quit the program

What would you like to do? 2

searching by city...

Enter a city: Windsor

Here are all the cities I can find that start
with WINDSOR and have contributions...

     WINDSOR, MA, 01270,  Democrat:     $250, Republican:      $0
     WINDSOR, CT, 06095,  Democrat:    $2750, Republican:      $0
WINDSOR LOCKS, CT, 06096,  Democrat:       $0, Republican:    $500
     WINDSOR, NY, 13865,  Democrat:     $200, Republican:      $0
     WINDSOR, CO, 80528,  Democrat:       $0, Republican:   $2703
     WINDSOR, CO, 80550,  Democrat:     $250, Republican:   $1350
     WINDSOR, CA, 95492,  Democrat:    $3600, Republican:   $6900

Please choose from the following menu.
  (1) search by zip code
  (2) search by city
  (3) search by state
  (4) quit the program

What would you like to do? 2

searching by city...

Enter a city: Los Angeles

Here are all the cities I can find that start
with LOS ANGELES and have contributions...

 LOS ANGELES, CA, 90001,  Democrat:    $2700, Republican:      $0
 LOS ANGELES, CA, 90002,  Democrat:     $500, Republican:      $0
 LOS ANGELES, CA, 90004,  Democrat:  $116966, Republican:    $250
 LOS ANGELES, CA, 90005,  Democrat:   $20200, Republican:      $0
 LOS ANGELES, CA, 90006,  Democrat:    $1000, Republican:      $0
 LOS ANGELES, CA, 90007,  Democrat:    $2700, Republican:      $0
 LOS ANGELES, CA, 90010,  Democrat:    $7400, Republican:      $0
 LOS ANGELES, CA, 90012,  Democrat:   $12050, Republican:      $0
 LOS ANGELES, CA, 90013,  Democrat:    $8850, Republican:   $2000
 LOS ANGELES, CA, 90014,  Democrat:   $15500, Republican:      $0
 LOS ANGELES, CA, 90015,  Democrat:   $22400, Republican:      $0
 LOS ANGELES, CA, 90016,  Democrat:    $4000, Republican:   $1000
 LOS ANGELES, CA, 90017,  Democrat:   $19301, Republican:      $0
 LOS ANGELES, CA, 90018,  Democrat:    $3850, Republican:      $0
 LOS ANGELES, CA, 90019,  Democrat:   $14715, Republican:      $0
 LOS ANGELES, CA, 90020,  Democrat:   $54000, Republican:      $0
 LOS ANGELES, CA, 90021,  Democrat:    $3151, Republican:    $500
 LOS ANGELES, CA, 90022,  Democrat:     $340, Republican:      $0
 LOS ANGELES, CA, 90023,  Democrat:     $400, Republican:      $0
 LOS ANGELES, CA, 90024,  Democrat:  $238470, Republican:  $27760
 LOS ANGELES, CA, 90025,  Democrat:  $117310, Republican:   $6350
 LOS ANGELES, CA, 90026,  Democrat:   $21329, Republican:    $250
 LOS ANGELES, CA, 90027,  Democrat:   $67708, Republican:   $1000
 LOS ANGELES, CA, 90028,  Democrat:   $27550, Republican:   $3200
 LOS ANGELES, CA, 90029,  Democrat:    $1500, Republican:      $0
 LOS ANGELES, CA, 90031,  Democrat:    $3250, Republican:      $0
 LOS ANGELES, CA, 90032,  Democrat:     $500, Republican:      $0
 LOS ANGELES, CA, 90034,  Democrat:   $21900, Republican:      $0
 LOS ANGELES, CA, 90035,  Democrat:   $17000, Republican:  $10800
 LOS ANGELES, CA, 90036,  Democrat:  $107564, Republican:    $200
 LOS ANGELES, CA, 90038,  Democrat:   $35700, Republican:      $0
 LOS ANGELES, CA, 90039,  Democrat:   $19970, Republican:      $0
 LOS ANGELES, CA, 90040,  Democrat:     $753, Republican:      $0
 LOS ANGELES, CA, 90041,  Democrat:   $12500, Republican:    $200
 LOS ANGELES, CA, 90042,  Democrat:    $2200, Republican:      $0
 LOS ANGELES, CA, 90044,  Democrat:    $-300, Republican:      $0
 LOS ANGELES, CA, 90045,  Democrat:   $13261, Republican:    $250
 LOS ANGELES, CA, 90046,  Democrat:    $7905, Republican:    $500
 LOS ANGELES, CA, 90047,  Democrat:     $200, Republican:    $500
 LOS ANGELES, CA, 90048,  Democrat:   $84450, Republican:    $250
 LOS ANGELES, CA, 90049,  Democrat:  $375105, Republican:  $29400
 LOS ANGELES, CA, 90051,  Democrat:     $250, Republican:      $0
 LOS ANGELES, CA, 90056,  Democrat:   $13800, Republican:   $1000
 LOS ANGELES, CA, 90057,  Democrat:    $1500, Republican:    $250
 LOS ANGELES, CA, 90062,  Democrat:     $500, Republican:      $0
 LOS ANGELES, CA, 90064,  Democrat:  $141000, Republican:   $5200
 LOS ANGELES, CA, 90065,  Democrat:   $18267, Republican:      $0
 LOS ANGELES, CA, 90066,  Democrat:   $36681, Republican:   $6400
 LOS ANGELES, CA, 90067,  Democrat:  $185768, Republican:  $21700
 LOS ANGELES, CA, 90068,  Democrat:  $134565, Republican:    $250
 LOS ANGELES, CA, 90069,  Democrat:  $259366, Republican:      $0
 LOS ANGELES, CA, 90071,  Democrat:   $19650, Republican:    $750
 LOS ANGELES, CA, 90074,  Democrat:     $190, Republican:      $0
 LOS ANGELES, CA, 90077,  Democrat:  $121870, Republican:  $24100
 LOS ANGELES, CA, 90089,  Democrat:    $5400, Republican:      $0
 LOS ANGELES, CA, 90094,  Democrat:    $6650, Republican:      $0
 LOS ANGELES, CA, 90095,  Democrat:    $1200, Republican:      $0
 LOS ANGELES, CA, 91401,  Democrat:     $450, Republican:      $0

Please choose from the following menu.
  (1) search by zip code
  (2) search by city
  (3) search by state
  (4) quit the program

What would you like to do? 3
Enter a two digit state code: Pennsylvania
That is not a valid state abbreviation
Enter a two digit state code: 3
That is not a valid state abbreviation
Enter a two digit state code: PA

Top five contribution zip codes for Clinton in PA:
    PHILADELPHIA, PA 19103: 69 contributions totalling $124630
        SCRANTON, PA 18509: 41 contributions totalling  $58525
      PITTSBURGH, PA 15217: 43 contributions totalling  $54400
       BRYN MAWR, PA 19010: 23 contributions totalling  $46300
    PHILADELPHIA, PA 19106: 26 contributions totalling  $36420

Top five contribution zip codes for Cruz in PA:
      PITTSBURGH, PA 15238: 24 contributions totalling  $36575
        GLADWYNE, PA 19035:  3 contributions totalling  $11800
    FAYETTE CITY, PA 15438:  6 contributions totalling  $10000
    BELLE VERNON, PA 15012:  6 contributions totalling  $10000
      WASHINGTON, PA 15301:  7 contributions totalling   $7750

Top five contribution zip codes for Kasich in PA:
     CHADDS FORD, PA 19317:  2 contributions totalling   $5400
      PITTSBURGH, PA 15238:  3 contributions totalling   $4000
CRANBERRY TOWNSHIP, PA 16066:  2 contributions totalling   $3700
        NAZARETH, PA 18064:  1 contributions totalling   $2700
   STATE COLLEGE, PA 16801:  1 contributions totalling   $2700

Top five contribution zip codes for Sanders in PA:
    PHILADELPHIA, PA 19147: 18 contributions totalling   $9600
    PHILADELPHIA, PA 19119: 11 contributions totalling   $5190
      PITTSBURGH, PA 15208:  9 contributions totalling   $5150
      PITTSBURGH, PA 15228:  4 contributions totalling   $4000
        NEW HOPE, PA 18938:  8 contributions totalling   $3250

Top five contribution zip codes for Trump in PA:
         STEVENS, PA 17578:  1 contributions totalling   $2700
    CHAMBERSBURG, PA 17201:  1 contributions totalling   $2700
        CARLISLE, PA 17013:  1 contributions totalling   $2700
      PITTSBURGH, PA 15215:  1 contributions totalling   $2700
       BLUE BELL, PA 19422:  2 contributions totalling    $760


***Click anywhere in the graph window to continue.***

Please choose from the following menu.
  (1) search by zip code
  (2) search by city
  (3) search by state
  (4) quit the program

What would you like to do? 4
OK.  Goodbye!
Return to Lab 09