Exercise

Load and explore your Twitter data

Now that you've got your Twitter data sitting locally in a text file, it's time to explore it! This is what you'll do in the next few interactive exercises. In this exercise, you'll read the Twitter data into a list: tweets_data.

Be aware that this is real data from Twitter and as such there is always a risk that it may contain profanity or other offensive content (in this exercise, and any following exercises that also use real Twitter data).

Instructions

100 XP
  • Assign the filename 'tweets.txt' to the variable tweets_data_path.
  • Initialize tweets_data as an empty list to store the tweets in.
  • Within the for loop initiated by for line in tweets_file:, load each tweet into a variable, tweet, using json.loads(), then append tweet to tweets_data using the append() method.
  • Hit submit and check out the keys of the first tweet dictionary printed to the shell.