1. Introduction
  2. Simple Types
  3. Lists
  4. Sorting
  5. Dicts
  6. Files
  7. Fetching Data from the Internet
  8. Simple Data Analysis
  9. Exercises
    1. Basic exercises
    2. OS Names API
    3. Life expectancy tables
    4. Copy special
    5. Log puzzle

Processing Life Expectancy Tables

The Office for National Statistics (ONS) produces life expectancy at birth tables for various geographies for England and Wales. However, because they are statisticians they produce nasty broken Excel sheets instead of nice simple (and easy to use) CSV files.

In this exercise we will be taking a pair of raw data files (counties-m-birth.csv and counties-f-birth.csv) that have been saved out from Excel as CSV. They contain male and female life expectancies at birth for English counties. You will need to edit the file life_expectancy.py and add in some code to extract the lines we want (a header row and the ones with figures on), and then output them for each file.

If you finish that task then you can think on how you might add the ability to sort the rows based on a column the user specifies, or how you could combine the male and female figures to allow them to be compared more easily.