While working with computers, we all have worked with files and directories. A file is “a collection of data or information that has a name.”1 We can use files to store programs, text, and other structured information.
Throughout this chapter you will see files referred to as streams. You can think of a sequence of data arriving on a conveyor belt or like water in a stream. The file input/output methods we will be describing will work for many types of stream data.
Objectives
Upon completion of this chapter’s exercises, you should be able to:
- Employ files to retrieve and store plain text.
- Demonstrate different methods for reading sequential data.
- Modify an existing file to add new data to the end of it.
- Use Python’s context manager to manage a finite resource.
- Utilize data in the CSV format in a program.
1http://www.webopedia.com/TERM/F/file.html retrieved 2017-04-13