Table of Contents

Class CsvReader<T>

Namespace
FlameCsv.Reading
Assembly
FlameCsv.Core.dll

Reads CSV records.

public sealed class CsvReader<T> : RecordOwner<T>, IDisposable, IAsyncDisposable where T : unmanaged, IBinaryInteger<T>

Type Parameters

T
Inheritance
object
CsvReader<T>
Implements
Inherited Members

Remarks

This class is used internally by the library and doesn't expose high-level CSV reading functionality. Use ParseRecords() and ParseRecordsAsync(CancellationToken) to enumerate the CSV records from ther reader.

Constructors

CsvReader(CsvOptions<T>, ICsvBufferReader<T>, in CsvIOOptions)

Initializes a new instance of the CsvReader<T> class.

public CsvReader(CsvOptions<T> options, ICsvBufferReader<T> reader, in CsvIOOptions ioOptions = default)

Parameters

options CsvOptions<T>
reader ICsvBufferReader<T>
ioOptions CsvIOOptions

CsvReader(CsvOptions<T>, in ReadOnlySequence<T>, in CsvIOOptions)

Initializes a new instance of the CsvReader<T> class.

public CsvReader(CsvOptions<T> options, in ReadOnlySequence<T> csv, in CsvIOOptions ioOptions = default)

Parameters

options CsvOptions<T>
csv ReadOnlySequence<T>
ioOptions CsvIOOptions

CsvReader(CsvOptions<T>, ReadOnlyMemory<T>, in CsvIOOptions)

Initializes a new instance of the CsvReader<T> class.

public CsvReader(CsvOptions<T> options, ReadOnlyMemory<T> csv, in CsvIOOptions ioOptions = default)

Parameters

options CsvOptions<T>
csv ReadOnlyMemory<T>
ioOptions CsvIOOptions

Properties

IsDisposed

Indicates whether the reader has been disposed.

public override bool IsDisposed { get; }

Property Value

bool

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

GetAsyncEnumerator(CancellationToken)

Returns an enumerator that asynchronously iterates through the CSV data.

public CsvReader<T>.AsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

CsvReader<T>.AsyncEnumerator

Remarks

The enumerator advances the inner reader and parser, and disposes them after use.

GetEnumerator()

Returns an enumerator that iterates through the CSV data.

public CsvReader<T>.Enumerator GetEnumerator()

Returns

CsvReader<T>.Enumerator

Remarks

The enumerator advances the inner reader and parser, and disposes them after use.

ParseRecords()

Returns an enumerator that iterates through the CSV data.

public CsvReader<T>.RecordEnumerable ParseRecords()

Returns

CsvReader<T>.RecordEnumerable

Remarks

The enumerator advances the inner reader and parser, and disposes them after use.

ParseRecordsAsync(CancellationToken)

Returns an enumerator that asynchronously iterates through the CSV data.

public CsvReader<T>.RecordAsyncEnumerable ParseRecordsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

CsvReader<T>.RecordAsyncEnumerable

Remarks

The enumerator advances the inner reader and parser, and disposes them after use.

Reset()

Resets the reader to the beginning of the data source.

public void Reset()

Exceptions

NotSupportedException

The inner data source does not support rewinding.

TryReset()

Attempts to reset the reader to the beginning of the data source.

public bool TryReset()

Returns

bool

true if the inner data source supports rewinding and was successfully reset; otherwise false.