CSV Dictionary Reader

Learn about the CSV dictionary reader and its practical implementation.

Overview

We can read CSV files as a sequence of strings, or as a dictionary. When we read the file as a sequence of strings, there are no special provisions for column headers. We’re forced to manage the details of which column has a particular attribute. This is unpleasantly complex, but sometimes necessary.

We can also read a CSV file so each row becomes a dictionary. We can provide a sequence of keys, or the first line of the file can provide the keys. This is relatively common, and it saves a little bit of confusion when the column headers are part of the data.

Bezdek Iris data

We’ve been looking at the Bezdek Iris data for our case study. There’s a copy of the data in the Kaggle repository. The data is also available at the U ...