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
recordTThe record to fill each enumeration.
cancellationTokenCancellationTokenThe cancellation token to stop the writing.
Returns
- IAsyncEnumerable<T>
An IAsyncEnumerable<T> of records.
Type Parameters
TThe 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
recordTThe record to fill each enumeration.
Returns
- IEnumerable<T>
An IEnumerable<T> of records.
Type Parameters
TThe 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
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
typeTypeThe Type of the record.
cancellationTokenCancellationTokenThe 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
cancellationTokenCancellationTokenThe cancellation token to stop the writing.
Returns
- IAsyncEnumerable<T>
An IAsyncEnumerable<T> of records.
Type Parameters
TThe 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
anonymousTypeDefinitionTThe anonymous type definition to use for the records.
cancellationTokenCancellationTokenThe cancellation token to stop the writing.
Returns
- IAsyncEnumerable<T>
An IAsyncEnumerable<T> of records.
Type Parameters
TThe 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
TThe 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
anonymousTypeDefinitionTThe anonymous type definition to use for the records.
Returns
- IEnumerable<T>
An IEnumerable<T> of records.
Type Parameters
TThe 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
ReadHeader()
Reads the header record without reading the first row.
bool ReadHeader()
Returns
- bool
True if there are more records, otherwise false.