CSV Dictionary Reader
Learn about the CSV dictionary reader and its practical implementation.
We'll cover the following
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 UCI Machine Learning Repository. The UCI Machine Learning Repository file, bezdekIris.data
, does not have column titles; these are provided separately in a file named iris.names
.
The iris.names
file has a great deal of information in it, including this in section 7 of the document:
Get hands-on with 1400+ tech skills courses.