Who in Congress is on Twitter? (DRAFT)

Parsing JSON
This assignment is due on Friday, February 12
9 exercises
4.5 possible points
Create a subfolder named 0015-congress-twitter-profiles inside your compciv-2016/exercises folder.

Summary

DRAFT

Table of contents

The Checklist

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

     exercises/0015-congress-twitter-profiles

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

        compciv-2016
        └── exercises
            └── 0015-congress-twitter-profiles
               ├── a.py
               ├── b.py
               ├── c.py
               ├── d.py
               ├── e.py
               ├── f.py
               ├── g.py
               ├── h.py
               ├── i.py
    
a.py 0.5 points Download and count the number of Twitter accounts operated by Congressmembers
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
g.py 0.5 points TK
h.py 0.5 points TK
i.py 0.5 points TK

Background information

Twitter's API documentation for the user profile data can be found here: [](https://dev.twitter.com/rest/reference/get/users/show)

The data file can be found here:

http://stash.compciv.org/congress-twitter/2016-01/congress-twitter-profiles.json

Examples of individual profiles as JSON files:

a. download b.

  • Find the congressmember with the most followers
  • Find the congressmember who has the oldest Twitter account
  • Find the congressmember who has highest average tweets per day since their account started
  • List the 5 congressmembers with 5 highest averages
  • find the congress member with the oldest most recent tweet
  • count number of congressmembers who sent their latest tweet via an iphone
  • List the devices or programs used by congressmembers to send their most recent tweets, sorted in order of frequency
  • List every website mentioned in a congressmember's recent tweet, in order of frequency

The Exercises

0015-congress-twitter-profiles/a.py » Download and count the number of Twitter accounts operated by Congressmembers

0015-congress-twitter-profiles/a.py
Download and count the number of Twitter accounts operated by Congressmembers
0.5 points
  • Make a tempdata subdirectory inside this working directory.
  • Download the JSON file of Twitter profiles (this may take awhile)
  • Count the lines and print the number.

The file can be found here:

http://stash.compciv.org/congress-twitter/2016-01/congress-twitter-profiles.json

Expectations

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

0015-congress-twitter-profiles $ python a.py
  • The program's output to screen should be:
    There are 83556 lines in tempdata/congress-twitter-profiles.json
Some takeaways from this exercise:
  • Note that the number of lines in the file do not correspond to number of Twitter accounts.

0015-congress-twitter-profiles/b.py » TK

0015-congress-twitter-profiles/b.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python b.py
  • The program's output to screen should be:
    TK
    

0015-congress-twitter-profiles/c.py » TK

0015-congress-twitter-profiles/c.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python c.py
  • The program's output to screen should be:
    TK
    

0015-congress-twitter-profiles/d.py » TK

0015-congress-twitter-profiles/d.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python d.py
  • The program's output to screen should be:
    TK
    

0015-congress-twitter-profiles/e.py » TK

0015-congress-twitter-profiles/e.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python e.py
  • The program's output to screen should be:
    TK
    

0015-congress-twitter-profiles/f.py » TK

0015-congress-twitter-profiles/f.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python f.py
  • The program's output to screen should be:
    TK
    

0015-congress-twitter-profiles/g.py » TK

0015-congress-twitter-profiles/g.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python g.py
  • The program's output to screen should be:
    TK
    

0015-congress-twitter-profiles/h.py » TK

0015-congress-twitter-profiles/h.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python h.py
  • The program's output to screen should be:
    TK
    

0015-congress-twitter-profiles/i.py » TK

0015-congress-twitter-profiles/i.py
TK
0.5 points

TK

Expectations

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

0015-congress-twitter-profiles $ python i.py
  • The program's output to screen should be:
    TK