Skip to content

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

License

Notifications You must be signed in to change notification settings

YunaBraska/csv-streamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, ','); 

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages