From the course: Data Science for Java Developers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Converting CSVs to data objects

Converting CSVs to data objects - Java Tutorial

From the course: Data Science for Java Developers

Converting CSVs to data objects

- [Instructor] So the next step, now that we have our CSV loader and parse CSV functions is to actually create a data class for our grocery records, as well as create a method that will actually take our list of CSV records here and sort of translate that into our data objects. Okay so let's create a new class here. We're going to call that something like grocery record. And this is going to contain the attributes that we have up here. There are only three in this case. So we're going to have member number, date and item description. We're going to say public final string member number, public final date, date. We're going to have to import date of course, the one from Java.util in case that gives you the option. And then we're going to say public final string item description. And we're going to generate a constructor for that as well as a two string method. Okay, so implementing that data class was fairly…

Contents