Reading CSV files with reader objects
This recipe will show you how to read CSV files, specifically how to create and use the reader object.
To step through this recipe, you will need to install Python v2.7. To work with the CSV files, we have a nice module,
csv, which is packaged with the default Python installation. So, let's get started!
How to do it...
- On your Linux/Mac computer, go to Terminal and use Vim, or choose your favorite editor.
- We start by creating a CSV file. As we know, a CSV file has a structured format where data is separated by commas, so creating one should be trivial. The following screenshot is of a CSV file that contains details of contacts in different parts of the country. We name it as
- Now, let's ...