CSE 1710.03A Programming for Digital Media

Lab 09

Due date: Nov 16, 2009 at 20:00

Changing a WWW page

Assume you are given a WWW page that has lot's of dates in it and your task is to change some of the dates. For simplicity, this lab will concentrate only on years.

As an example scenario for this task, you are given a copy of the WWW page for the History of Austria. Assuming that historical research has shown that all records for the period from 1700 to 1799 are off by two years, you are now asked to fix all dates by decreasing each year number in that interval by two.

For this, you have to write a function fixDates(originalfile,output) which reads the file named originalfile and writes the result to the file named output.

You must name your program lab09.py.

As a starting point, you can use the following code segment, which opens a file, checks if the text "WINNER" appears in it and prints also the name that appears after the word WINNER in the text.

  file = open(name,"rt")
  text = file.read()
  # Search for WINNER followed by a space and a 10 character name
  position = text.find("WINNER")
  if position <> -1: 
    print "Found a Winner:", text[position+8:position+18]
  file.close()
Here are a couple of hints:

What to Turn in

As mentioned previously, you have to add comments with your own identification (name, student ID, date). Remember to save the file after you modify it!

How to submit the lab

For details on how to submit, please refer to lab2. However, this time please submit to lab09, i.e. issue the command

submit 1710 lab09 lab09.py

Note: You must do all the above steps correctly for receiving full credit for this labtest.