Lab: File I/O

Reading and writing from files

I have created a data file with 100 fake students' scores in it. On each line there is a first name, a last name and 20 scores, all separated by tab characters. Your job is to read in this file, find the average score for each student, and write that information out to a new file. The new file should contain one line for each student with first name, last name and their average, separated by tab characters.

When you write your lines to the file, use the format function rather than concatenating in order to separate them by tabs. \t is the special escape character for tab.

Download the data file into the same directory you're code file is in.

Things That Might be Useful

  • Slides from Thursday on file I/O
  • Slides from today on format
  • The string split method