ABSTRACT

This chapter shows how to read and write any text file. Reading and saving files are an important part of most programs. Reading a file is a three-step process in Python: Open the file, Read the file and Close the file. The chapter shows how to parse data separated by a special character such as a comma, a semicolon or the tab character. The process of determining the syntactic structure of an expression to retrieve a specific part for further analysis is called parsing. While doing data processing work, it's very common to run into a file type called Comma Separated Values (CSV). There are more actions with files besides reading and writing. Copy, move, delete, list, change directory, set file properties, and others can be done with os, shutil, and path.py modules. The os module handles an interface with the Operating System.