Course material for JU2602 Data journalism and visualization
This page contain Python code and Jupyter Notebooks for the course JU2602 Data journalism and visualization, part of the master programme in investigative journalism at JMG, Sweden.
The goal is to learn the basics of programming in general and Python in particular. No previous programming knowledge is required. The goal is to build a news robot that can scrape the web and automatically write a news article.
Please bring your computer!
Contact Peter M. Dahlgren if you have any questions.
Overview of what we’ll do, apart from the lectures:
if
-statements and for
-loops.def
that group code into reusable blocks.Exercise | Goal |
---|---|
Exercise 1: Variables | Create, change and combine variables. |
Exercise 2: Strings | Manipulate text strings. |
Exercise 3: If-statements | Control program flow with if, elif and else. |
Exercise 4: For-loops | Use for-loops to control how lists are presented on the screen. |
Exercise 5: Functions (def) | Create functions that take input, change the input, and then return some new value. |
Exercise 6: Error handling | Understand common error messages, and how to solve them. |
Project | Description |
---|---|
Scrape Court Rulings from InfoCuria | Scrape most recent judgments and opinions from InfoCuria. |
Web Scraping Examples | Example code for scraping Internet Movie Database, Washington Post and Wikipedia. |
Model Scraper | Student project that scrape body measurements from women models. |
Facebook API | Get Facebook status messages from any Facebook page. |
BeautifulSoup Examples | Example code to help you scrape HTML from web pages using BeautifulSoup. |
Movie Review News Robot | News robot that writes a news article based on movie data. |
Earthquake News Robot | News robot that writes a news article based on (fictitious) earthquake data. |
Weather News Robot | News robot that scrapes tomorrows weather and writes a short text complaining about how cold it is. |
Ctrl+Enter
= run cellESC
= exit out of a cellTab
= autocompletea
= insert cell aboveb
= insert cell belowdd
= delete cellJupyter Notebook files are saved on your computer, typically in your Users folder (i.e., /Users/<username>
). Read more at 28 Jupyter Notebook tips, tricks and shortcuts.