FastCsvReader

Ecng.IO

Provides fast CSV reading capabilities from various input sources.

Herda de: Disposable

Construtores

FastCsvReader
public FastCsvReader(Stream stream, Encoding encoding, string lineSeparator)
fastCsvReader = FastCsvReader(stream, encoding, lineSeparator)

Initializes a new instance of the FastCsvReader class using a stream, encoding, and line separator.

stream
The input stream to read CSV data from.
encoding
The character encoding to use.
lineSeparator
The string that separates lines.
FastCsvReader
public FastCsvReader(TextReader reader, string lineSeparator, bool leaveOpen)
fastCsvReader = FastCsvReader(reader, lineSeparator, leaveOpen)

Initializes a new instance of the FastCsvReader class using a TextReader and line separator.

reader
The TextReader to read CSV data from.
lineSeparator
The string that separates lines.
leaveOpen
Specifies whether the reader should remain open after the FastCsvReader is disposed.
FastCsvReader
public FastCsvReader(TextReader reader, string lineSeparator)
fastCsvReader = FastCsvReader(reader, lineSeparator)

Initializes a new instance of the FastCsvReader class using a TextReader and line separator.

reader
The TextReader to read CSV data from.
lineSeparator
The string that separates lines.
FastCsvReader
public FastCsvReader(string content, string lineSeparator)
fastCsvReader = FastCsvReader(content, lineSeparator)

Initializes a new instance of the FastCsvReader class using a string content and line separator.

content
The string content to read CSV data from.
lineSeparator
The string that separates lines.
FastCsvReader
public FastCsvReader(Stream stream, Encoding encoding, string lineSeparator, bool leaveOpen)
fastCsvReader = FastCsvReader(stream, encoding, lineSeparator, leaveOpen)

Initializes a new instance of the FastCsvReader class using a stream, encoding, and line separator.

stream
The input stream to read CSV data from.
encoding
The character encoding to use.
lineSeparator
The string that separates lines.
leaveOpen
Specifies whether the stream should remain open after the FastCsvReader is disposed.

Propriedades

ColumnCount
public int ColumnCount { get; }
value = fastCsvReader.ColumnCount

Gets the number of columns in the current CSV line.

ColumnCurr
public int ColumnCurr { get; }
value = fastCsvReader.ColumnCurr

Gets the current column index being processed.

ColumnSeparator
public char ColumnSeparator { get; set; }
value = fastCsvReader.ColumnSeparator
fastCsvReader.ColumnSeparator = value

Gets or sets the character used to separate columns.

CurrentLine
public string CurrentLine { get; }
value = fastCsvReader.CurrentLine

Gets the current CSV line as a string.

Reader
public TextReader Reader { get; }
value = fastCsvReader.Reader

Gets the underlying text reader.

Métodos

DisposeManaged
protected override void DisposeManaged()
fastCsvReader.DisposeManaged()

Disposes the managed resources. Override this method to add custom clean up of managed resources.

NextLineAsync
public ValueTask<bool> NextLineAsync(CancellationToken cancellationToken)
result = fastCsvReader.NextLineAsync(cancellationToken)

Asynchronously reads the next CSV line from the underlying stream or reader.

cancellationToken
Cancellation token.

Retorna: true if a new line was successfully read; otherwise, false.

ReadBool
public bool ReadBool()
result = fastCsvReader.ReadBool()

Reads the next column as a boolean value.

Retorna: The boolean value read from the column.

ReadDateTime
public DateTime ReadDateTime(string format)
result = fastCsvReader.ReadDateTime(format)

Reads the next column as a DateTime value using the specified format.

format
The date and time format string.

Retorna: The DateTime value read from the column.

ReadDecimal
public decimal ReadDecimal()
result = fastCsvReader.ReadDecimal()

Reads the next column as a decimal value.

Retorna: The decimal value read from the column.

ReadDouble
public double ReadDouble()
result = fastCsvReader.ReadDouble()

Reads the next column as a double value.

Retorna: The double value read from the column.

ReadEnum``1
public T ReadEnum<T>()
result = fastCsvReader.ReadEnum()

Reads the next column as an enum value of type .

Retorna: The enum value read from the column.

ReadInt
public int ReadInt()
result = fastCsvReader.ReadInt()

Reads the next column as an integer value.

Retorna: The integer value read from the column.

ReadLong
public long ReadLong()
result = fastCsvReader.ReadLong()

Reads the next column as a long value.

Retorna: The long value read from the column.

ReadNullableBool
public bool? ReadNullableBool()
result = fastCsvReader.ReadNullableBool()

Reads the next column as a nullable boolean value.

Retorna: A nullable boolean value read from the column, or null if the column is empty.

ReadNullableDateTime
public DateTime? ReadNullableDateTime(string format)
result = fastCsvReader.ReadNullableDateTime(format)

Reads the next column as a nullable DateTime value using the specified format.

format
The date and time format string.

Retorna: A nullable DateTime value read from the column, or null if the column is empty.

ReadNullableDecimal
public decimal? ReadNullableDecimal()
result = fastCsvReader.ReadNullableDecimal()

Reads the next column as a nullable decimal value.

Retorna: A nullable decimal value read from the column, or null if the column is empty.

ReadNullableDouble
public double? ReadNullableDouble()
result = fastCsvReader.ReadNullableDouble()

Reads the next column as a nullable double value.

Retorna: A nullable double value read from the column, or null if the column is empty.

ReadNullableEnum``1
public T? ReadNullableEnum<T>()
result = fastCsvReader.ReadNullableEnum()

Reads the next column as a nullable enum value of type .

Retorna: A nullable enum value read from the column, or null if the column is empty.

ReadNullableInt
public int? ReadNullableInt()
result = fastCsvReader.ReadNullableInt()

Reads the next column as a nullable integer value.

Retorna: A nullable integer value read from the column, or null if the column is empty.

ReadNullableLong
public long? ReadNullableLong()
result = fastCsvReader.ReadNullableLong()

Reads the next column as a nullable long value.

Retorna: A nullable long value read from the column, or null if the column is empty.

ReadNullableTimeSpan
public TimeSpan? ReadNullableTimeSpan(string format)
result = fastCsvReader.ReadNullableTimeSpan(format)

Reads the next column as a nullable TimeSpan value using the specified format.

format
The time span format string.

Retorna: A nullable TimeSpan value read from the column, or null if the column is empty.

ReadString
public string ReadString()
result = fastCsvReader.ReadString()

Reads the next column as a string.

Retorna: The string read from the column, or null if the column is empty.

ReadTimeSpan
public TimeSpan ReadTimeSpan(string format)
result = fastCsvReader.ReadTimeSpan(format)

Reads the next column as a TimeSpan value using the specified format.

format
The time span format string.

Retorna: The TimeSpan value read from the column.

Skip
public void Skip(int count)
fastCsvReader.Skip(count)

Skips the specified number of columns.

count
The number of columns to skip. Defaults to 1.