orangesignal / orangesignal-csv

CSV (comma-separated values) read and write library for Java.
http://orangesignal.github.io/orangesignal-csv
Apache License 2.0
43 stars 22 forks source link

OrangeSignal CSV Build Status

OrangeSignal CSV is a very flexible csv (comma-separated values) read and write library for Java.

The binary distributions includes the following third party software:
jLHA (LHA Library for Java).

Prerequisites

Installation

Maven users

If you are using Maven, simply copy the following dependency into your pom.xml file. The artifact is hosted at Maven Central, and is standalone (no dependencies).

<dependency>
    <groupId>com.orangesignal</groupId>
    <artifactId>orangesignal-csv</artifactId>
    <version>2.2.1</version>
</dependency>

Examples

CSV entity class

@CsvEntity(header = true)
public class Customer {

    @CsvColumn(name = "name")
    public String name;

    @CsvColumn(name = "age")
    public Integer age;

}

example code

CsvConfig cfg = new CsvConfig(',', '"', '"');
cfg.setNullString("NULL");
cfg.setIgnoreLeadingWhitespaces(true);
cfg.setIgnoreTrailingWhitespaces(true);
cfg.setIgnoreEmptyLines(true);
cfg.setIgnoreLinePatterns(Pattern.compile("^#.*$"));
cfg.setVariableColumns(false);

List<Customer> list = new CsvEntityManager()
    .config(cfg)
    .load(Customer.class)
    .filter(new SimpleBeanFilter().in("name", "Smith", "Johnson").gt("age", 21))
    .offset(10)
    .limit(1000)
    .order(BeanOrder.desc("age"))
    .from(reader);

How to use

Sorry, it is japanese only for now.

License