Project 1 - Energy Usage Stories
Due 10pm Tuesday April 15



In this project we will build some Python classes that a programmer can use to tell stories about energy use by American households on Web pages. When we grade this assignment, we'll use the classes you write to create a couple of different Web pages.

Here is the program main.py that uses the classes you should write to create the Web page above. You can see that the classes are in another module, eiaClass.py. That is the module you should write.

The Datasource class will read data from the input spreadsheet CE3.1Site_End-Use_Consumption_in_US.csv. It has a method called report that returns one line of data. We'll concentrate on columns 8-12 (starting counting with column zero), that show how households use energy; the rest of the columns can be igonred. Since the file is in the .csv format, you know the interesting data items on each line are separated by commas, so you could get at them by using the Python split method on each line. Or, you could try using the csv module. The data comes from this page at the US Energy Information Administration.

The Chart class takes a line of data as input and makes a pie chart using the Google Visualization API. Your job is not to understand this API right now (we'll get to that!). You just need to be able to work with the example on the very first page of the tutorial. The Chart class has a method addData that puts the data into the chart.

Finally, the the HTML_Page class produces a Web page that tells the story. It has three methods, title, text, and chart, that add the corresponding features to the Web page. If one is not added, it will be missing from the output Web page, but a Web page should still be created. You should be able to add the features in any order. The output Web page should be called story.html. For now, just produce plain HMTL. Next week we will discuss CSS a bit and provide some CSS that you can use to make the Web page look classy. Watch this space!

References: