1.1-Introductie-Programmeren

Reading numbers from a file: Using the Csv Reader

Difficulty: Filled Filled Outlined

Besides adding data into lists manually, we can also load data from files. This exercise is all about learning how to do this.

Using the CsvReader (this comes along with the SaxionApp) to read out a list of ages from various Saxion students (data can be found in ages.csv. Once the list is filled with these numbers, calculate the average age of the Saxion students (present in the file).

To help you out, we have given you some example code to work with so that you may learn how the CsvReader works. The most important thing to know is how to use the loadRow and getXXX methods (where XXX must be some type, like getInt).

Examples

Example