Table of Contents

Class CsvParser<T>

Namespace
FlameCsv.Reading
Assembly
FlameCsv.Core.dll

Reads CSV records from a ReadOnlySequence<T>.

public abstract class CsvParser<T> : CsvParser, IDisposable, IAsyncDisposable where T : unmanaged, IBinaryInteger<T>

Type Parameters

T
Inheritance
CsvParser<T>
Implements
Inherited Members

Remarks

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

Properties

IsDisposed

Whether the instance has been disposed.

protected bool IsDisposed { get; }

Property Value

bool

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()

Dispose(bool)

Disposes the instance.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Whether the method was called from 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 CsvParser<T>.RecordEnumerable ParseRecords()

Returns

CsvParser<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 CsvParser<T>.RecordAsyncEnumerable ParseRecordsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

CsvParser<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>, bool)

Attempts to read a complete CSV record from the read-ahead buffer, or from the data buffered from the inner reader.

public bool TryReadLine(out CsvFields<T> fields, bool isFinalBlock)

Parameters

fields CsvFields<T>

Fields of the CSV record up to the newline

isFinalBlock bool

Determines whether any more data can be expected after this read. When true, the parser will return leftover data even without a trailing newline.

Returns

bool

true if a record was read, false if no record can be read from the underlying data or the read-ahead buffer.

TryReadUnbuffered(out CsvFields<T>, bool)

Attempts to read a complete CSV record from the underlying data source. If newline is empty, the first call to this method will auto-detect the newline.

public bool TryReadUnbuffered(out CsvFields<T> fields, bool isFinalBlock)

Parameters

fields CsvFields<T>

Fields of the CSV record up to the newline

isFinalBlock bool

Determines whether any more data can be expected after this read. When true, the parser will return leftover data even without a trailing newline.

Returns

bool

true if a record was read, false if no record can be read from the underlying data.

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.