CSV Parser

@aljunggren aljunggren authored on 8 Jan 2022
src Updated ParserUtils columnToInt 5 years ago
.gitignore Initial commit 5 years ago
README.md Updated readme 4 years ago
lombok.config Initial commit 5 years ago
pom.xml Initial commit 5 years ago
README.md

CSV-Parser

Parse CSV and map to a given class.

Parser parser = new Parser();
List<MyClass> results = parser.parse(file, MyClass.class);

Mark first row as header

parser.firstRowIsHeader();

Set Delimiter

parser.delimiter(',');

Note: Default is comma

Annotate private member variables with @CSVColumn. Set value equal to the name of the column as viewed in Excel

@CSVColumn("A")

Defining class map

public class MyClass {
    @CSVColumn("A")
    private String firstName;
    
    @CSVColumn("B")
    private String lastName;
    
    @CSVColumn("G")
    private int age;
    
    // Getters & Setters
}

CSV Date

Converts value to Date

@CSVDate(pattern = "MM-dd-yyyy")

Data types supported

  • Date

Format used by java.text.SimpleDateFormat