Class CsvReader<T>

java.lang.Object
de.siegmar.fastcsv.reader.CsvReader<T>
Type Parameters:
T - the type of the CSV record.
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<T>

public final class CsvReader<T> extends Object implements Iterable<T>, Closeable

This is the main class for reading CSV data.

The CSV records are read iteratively, regardless of whether the Iterable, the Iterator, or the Stream is used. Once all records are read, the data is consumed. If you need to repeatedly read records, you should collect the records in a List or another collection.

Example use:

try (CsvReader<CsvRecord> csv = CsvReader.builder().ofCsvRecord(file)) {
    for (CsvRecord csvRecord : csv) {
        // ...
    }
}

Example for named records:

try (CsvReader<NamedCsvRecord> csv = CsvReader.builder().ofNamedCsvRecord(file)) {
    for (NamedCsvRecord csvRecord : csv) {
        // ...
    }
}