CS 0008: Fall 2015 Lab 9 YOUR NAME: YOUR PARTNER'S NAME: To get credit, you need to attend Lab and work throughout the session with your partner. Good News! This Lab will get you started on Assignment 4. It will give you practice inputting data from files, and with using dictionaries. Since this will be part of your solution to Assignment 4, you do not need to hand in anything for this Lab at the start of the next Lab session. Also, it's fine for just this subset of your solution to Assignment 4 to be the same as your partner's solution. But, be sure to complete the rest of Assignment 4 separately. Your job is to read in data and create a dictionary as you will in Assignment 4, and produce the first part of the output required for Assignment 4. For this Lab, you will work with smallInput.txt from Assignment 4. The output file, lab4output.txt, is the output you should produce for this Lab. ==== Part 1: file name arguments For the first time, you will include the input file name as an argument when you call your program, and store the output of your program in a file. On MAC/Windows/Linux, you enter the following into the command line: python lab9.py smallInput.txt > myoutput.txt This saves the results in a file "myoutput.txt" To automatically determine if two files are the same, on MAC/Linux you can use the command "diff": diff smallInput.txt myoutput.txt On Windows, you can use the command "fc": fc smallInput.txt myoutput.txt The following program (lab9start.py.txt on the schedule) reads in and prints a file. Download and run it; be sure to ask the TAs for help if you can't get this working. import sys def inputMovieInfo(filename): '''filename (string) is the name of a file. Each line in filename contains a name followed by a list of movies, where commas separate the various names. Here is an example: Brad Pitt,Sleepers,Troy,Meet Joe Black,Oceans Eleven Read the data and print it, line by line.''' f = open(filename,'r') for line in f: # Get rid of the \n at the end of the line line = line.strip() print(line) return [] def main(): data = inputMovieInfo(sys.argv[1]) main() ==== Part 2: Extend the code to produce lab9output.txt You can use lab9start.py as a base. Add extra "debugging" print statements to your solution so far so you can see what is going on.