Skip to content

XDean/Fluent-CSV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fluent CSV

Build Status codecov.io Maven Central

Fluent and Flexible CSV Framework

Get it

<dependency>
    <groupId>com.github.XDean</groupId>
    <artifactId>fluent-csv</artifactId>
    <version>1.x</version>
</dependency>

You have a space-delimited file:

people.csv

id name desc
1 Mike 'Football&Basketball'
2 Dan 'Swim and walk'
3 Alex  

We can define domain class:

Person.java

@CsvConfig(splitor = ' ', quoter='\'')
class Person{
  @CSV
  int id;
  
  @CSV
  String name;
  
  @CSV(name="desc", optional=true, defaultValue="No Description")
  String description;
}

Then read data by FluentCSV

FluentCSV.create()
  .readConfig(Person.class) // read the class's CSV config
  .readBean(Person.class) // read as bean
  .from(Paths.get("people.csv")) // from the file
  .forEach(System.out::println);

You will get:

Sample.Person(id=1, name=Mike, description=Football&Basketball)
Sample.Person(id=2, name=Dan, description=Swim and walk)
Sample.Person(id=3, name=Alex, description=No Description)

About

Fluent and Flexible CSV Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages