Class CsvReader<T>
Reads CSV records.
public sealed class CsvReader<T> : RecordOwner<T>, IDisposable, IAsyncDisposable where T : unmanaged, IBinaryInteger<T>
Type Parameters
T
- Inheritance
-
objectRecordOwner<T>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
optionsCsvOptions<T>readerICsvBufferReader<T>ioOptionsCsvIOOptions
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
optionsCsvOptions<T>csvReadOnlySequence<T>ioOptionsCsvIOOptions
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
optionsCsvOptions<T>csvReadOnlyMemory<T>ioOptionsCsvIOOptions
Properties
IsDisposed
Indicates whether the reader has been disposed.
public override bool IsDisposed { get; }
Property Value
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
cancellationTokenCancellationToken
Returns
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
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
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
cancellationTokenCancellationToken
Returns
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
trueif the inner data source supports rewinding and was successfully reset; otherwisefalse.