Introducing the CSV module
The csv
module is designed to process CSV data in an iterative manner. Rather than reading the data and then processing it, the csv
module is designed to simultaneously read and process the data line by line.
This makes sense from an efficiency perspective. It takes less memory and less time to read and operate on the data entry by entry than it does to read the data as whole. For this reason, the csv
module is well suited to process very large data files that are too big to read into memory.
Additionally, because the csv
module is built-in, it will work with any Python installation, making it transferable. This is worth mentioning because it is a slight advantage of the csv
module over the pandas
module.
In the following exercise, I will demonstrate how to use the csv
module to read and process data.