Reading and writing CSV files
We will examine reading and writing CSV files here. CSV stands for Comma Separated Values. These files are just records arranged in rows with a row consisting of multiple values separated by commas (and sometimes other separator symbols, such as spaces or tabs). Instead of relying on ready-made libraries to do this, we will write our own small, extensible class for reading and writing data in CSV format.
The reason for this is that the file format is so simple it requires little more effort than reading a text file line by line. Therefore, the resulting code is simple, short, and will save you an extra dependency. Also, there does not seem to be a de facto standard for CSV access in Scala. It will serve us as an introduction to file access in Scala, which may come in handy if you need to read other weird file formats. Here is an example of a CSV file containing a part of the famous IRIS dataset. It is very commonly used to sanity test pattern recognition and...