Table of Contents

Class CsvReader<T>

Namespace
FlameCsv.Reading
Assembly
FlameCsv.Core.dll

Reads CSV records from a ReadOnlySequence<T>.

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

Type Parameters

T
Inheritance
CsvReader<T>
Implements

Remarks

Internal implementation detail, this type should probably not be used directly.

Constructors

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

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

public CsvReader(CsvOptions<T> options, ICsvBufferReader<T> reader)

Parameters

options CsvOptions<T>
reader ICsvBufferReader<T>

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

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

public CsvReader(CsvOptions<T> options, in ReadOnlySequence<T> csv)

Parameters

options CsvOptions<T>
csv ReadOnlySequence<T>

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

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

public CsvReader(CsvOptions<T> options, ReadOnlyMemory<T> csv)

Parameters

options CsvOptions<T>
csv ReadOnlyMemory<T>

Properties

Options

Current options instance.

public CsvOptions<T> Options { get; }

Property Value

CsvOptions<T>

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.

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.

TryAdvanceReader()

Attempt to read more data from the underlying data.

public bool TryAdvanceReader()

Returns

bool

true if more data was read; otherwise false.

Remarks

All further reads after returning false will also return false.

TryAdvanceReaderAsync(CancellationToken)

Attempt to read more data from the underlying data.

public ValueTask<bool> TryAdvanceReaderAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<bool>

true if more data was read; otherwise false.

Remarks

All further reads after returning false will also return false.

TryGetBuffered(out CsvFields<T>)

Attempts to return a complete CSV record from the read-ahead buffer.

[EditorBrowsable(EditorBrowsableState.Never)]
public bool TryGetBuffered(out CsvFields<T> fields)

Parameters

fields CsvFields<T>

Fields of the CSV record up to the newline

Returns

bool

true if a record was read, false if the read-ahead buffer is empty or the record is incomplete.

TryReadLine(out CsvFields<T>)

Attempts to read the next CSV record from the buffered data or read-ahead buffer.

public bool TryReadLine(out CsvFields<T> fields)

Parameters

fields CsvFields<T>

Returns

bool

TryReset()

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

public bool TryReset()

Returns

bool

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