Table of Contents

Interface IReader

Namespace
CsvHelper
Assembly
CsvHelper.dll

Defines methods used to read parsed data from a CSV file.

public interface IReader : IReaderRow, IDisposable
Inherited Members

Methods

EnumerateRecordsAsync<T>(T, CancellationToken)

Enumerates the records hydrating the given record instance with row data. The record instance is re-used and not cleared on each enumeration. This only works for streaming rows. If any methods are called on the projection that force the evaluation of the IEnumerable, such as ToList(), the entire list will contain the same instance of the record, which is the last row.

IAsyncEnumerable<T> EnumerateRecordsAsync<T>(T record, CancellationToken cancellationToken = default)

Parameters

record T

The record to fill each enumeration.

cancellationToken CancellationToken

The cancellation token to stop the writing.

Returns

IAsyncEnumerable<T>

An IAsyncEnumerable<T> of records.

Type Parameters

T

The type of the record.

EnumerateRecords<T>(T)

Enumerates the records hydrating the given record instance with row data. The record instance is re-used and not cleared on each enumeration. This only works for streaming rows. If any methods are called on the projection that force the evaluation of the IEnumerable, such as ToList(), the entire list will contain the same instance of the record, which is the last row.

IEnumerable<T> EnumerateRecords<T>(T record)

Parameters

record T

The record to fill each enumeration.

Returns

IEnumerable<T>

An IEnumerable<T> of records.

Type Parameters

T

The type of the record.

GetRecords(Type)

Gets all the records in the CSV file and converts each to Type T. The Read method should not be used when using this.

IEnumerable<object> GetRecords(Type type)

Parameters

type Type

The Type of the record.

Returns

IEnumerable<object>

An IEnumerable<T> of records.

GetRecordsAsync(Type, CancellationToken)

Gets all the records in the CSV file and converts each to Type T. The Read method should not be used when using this.

IAsyncEnumerable<object> GetRecordsAsync(Type type, CancellationToken cancellationToken = default)

Parameters

type Type

The Type of the record.

cancellationToken CancellationToken

The cancellation token to stop the writing.

Returns

IAsyncEnumerable<object>

An IAsyncEnumerable<T> of records.

GetRecordsAsync<T>(CancellationToken)

Gets all the records in the CSV file and converts each to Type T. The Read method should not be used when using this.

IAsyncEnumerable<T> GetRecordsAsync<T>(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token to stop the writing.

Returns

IAsyncEnumerable<T>

An IAsyncEnumerable<T> of records.

Type Parameters

T

The Type of the record.

GetRecordsAsync<T>(T, CancellationToken)

Gets all the records in the CSV file and converts each to Type T. The read method should not be used when using this.

IAsyncEnumerable<T> GetRecordsAsync<T>(T anonymousTypeDefinition, CancellationToken cancellationToken = default)

Parameters

anonymousTypeDefinition T

The anonymous type definition to use for the records.

cancellationToken CancellationToken

The cancellation token to stop the writing.

Returns

IAsyncEnumerable<T>

An IAsyncEnumerable<T> of records.

Type Parameters

T

The Type of the record.

GetRecords<T>()

Gets all the records in the CSV file and converts each to Type T. The Read method should not be used when using this.

IEnumerable<T> GetRecords<T>()

Returns

IEnumerable<T>

An IEnumerable<T> of records.

Type Parameters

T

The Type of the record.

GetRecords<T>(T)

Gets all the records in the CSV file and converts each to Type T. The read method should not be used when using this.

IEnumerable<T> GetRecords<T>(T anonymousTypeDefinition)

Parameters

anonymousTypeDefinition T

The anonymous type definition to use for the records.

Returns

IEnumerable<T>

An IEnumerable<T> of records.

Type Parameters

T

The Type of the record.

Read()

Advances the reader to the next record. This will not read headers. You need to call Read() then ReadHeader() for the headers to be read.

bool Read()

Returns

bool

True if there are more records, otherwise false.

ReadAsync()

Advances the reader to the next record. This will not read headers. You need to call ReadAsync() then ReadHeader() for the headers to be read.

Task<bool> ReadAsync()

Returns

Task<bool>

True if there are more records, otherwise false.

ReadHeader()

Reads the header record without reading the first row.

bool ReadHeader()

Returns

bool

True if there are more records, otherwise false.