Skip to content

Latest commit

 

History

History
115 lines (91 loc) · 4.95 KB

README.md

File metadata and controls

115 lines (91 loc) · 4.95 KB

CSV Streamer

Build Maintainable Coverage Issues Commit Dependencies License Central Tag Javadoc Size Label

Lazy CSV reader: plain java, no dependencies, streaming, resource reader, unzip, autodetect delimiters, Immutable, InnerCSV NullPointerException or IndexOutOfBoundsException

Classes

ClassName UsageType Description
StreamCSV static Stream methods (lazy)
ConsumeCSV static Consumer methods (lazy)
ListCsv static List methods (in memory)
CsvReader Object Configurable reader

Options

Options Type Default Description
Skip long -1 Lines to skip while reading csv
charset Charset UTF_8 Charset to use for decoding the CSV file
unzip boolean false On true detects and extracts the CSV file automatically
autoSep boolean false On true detects the separator automatically
separators char... ',' Splits the CSV rows at the given separator

Example listCsv

        final List<CsvRow> csvList = ListCsv.listCsv(EXAMPLE_CSV);

Example ConsumeCSV

        ConsumeCSV.consumeCsv(EXAMPLE_CSV,System.out::println);

Example StreamCSV

        try(final Stream<CsvRow> csvStream = StreamCSV.streamCSV(EXAMPLE_CSV)){
            csvStream.forEach(System.out::println);
        }

Example CsvReader

import static berlin.yuna.logic.CsvReader.csvReader;

public class CsvReaderTest {

    //configuration
    CsvReader reader = csvReader().skipLines(1).charset(UTF_8).separator(';').unzip(true).autoSep(true);

    //read
    List<CsvRow> allLines = reader.readAllRows(EXAMPLE_CSV);

    //consume
    reader.consume(EXAMPLE_CSV,System.out::println);

    //stream
    try(final Stream<CsvRow> lazyStream = reader.streamCSV(EXAMPLE_CSV)){
        lazyStream.forEach(System.out::println);
    }
}

Example InnerCSV

        final List<CsvRow> csvRows = ListCSV.listCSV(EXAMPLE_CSV)
        final CsvRow firstColumn = csvRows.get(0);
        final CsvRow innerCSV = firstColumn.get(0, ',');