Java API to make an object from a CSV file

Viewed 62991

I'm looking for a library that allows me to map a .csv contents to an object.

Something like:

public class Person {

    private String name;
    private int age;

    @CsvField("name")
    public String getName() {
        return this.name;
    }

    @CsvField("age")
    public int getAge() {
        return this.age;
    }
}

and then say something like:

final Person filledWithDataFromCsv = csvApi.load(csvFilepath, Person.class);

from the given CSV:

#name, age
tom, 11
jim, 32

Does anyone know of such an API, or one that does something similar. I don't want it to use annotations as a must, I just want to be able to load the file with one line of code and a predefined class.

5 Answers
Related