CsvFileReader
Ecng.IO
Class for reading from comma-separated-value (CSV) files
继承自: CsvFileCommon
实现: IDisposable
构造函数
CsvFileReader
public CsvFileReader(Stream stream, string lineSeparator, EmptyLineBehavior emptyLineBehavior)
csvFileReader = CsvFileReader(stream, lineSeparator, emptyLineBehavior)
Initializes a new instance of the CsvFileReader class for the specified stream.
- stream
- The stream to read from
- lineSeparator
- The line separator to use.
- emptyLineBehavior
- Determines how empty lines are handled
CsvFileReader
public CsvFileReader(string path, string lineSeparator, EmptyLineBehavior emptyLineBehavior)
csvFileReader = CsvFileReader(path, lineSeparator, emptyLineBehavior)
Initializes a new instance of the CsvFileReader class for the specified file path.
- path
- The name of the CSV file to read from
- lineSeparator
- The line separator to use.
- emptyLineBehavior
- Determines how empty lines are handled
CsvFileReader
public CsvFileReader(TextReader reader, string lineSeparator, EmptyLineBehavior emptyLineBehavior)
csvFileReader = CsvFileReader(reader, lineSeparator, emptyLineBehavior)
Initializes a new instance of the CsvFileReader class for the specified file path.
- reader
- The file reader.
- lineSeparator
- The line separator to use.
- emptyLineBehavior
- Determines how empty lines are handled
属性
BaseStream
public override Stream BaseStream { get; }
value = csvFileReader.BaseStream
Gets the underlying stream.
CurrLine
public string CurrLine { get; private set; }
value = csvFileReader.CurrLine
csvFileReader.CurrLine = value
The current line being read.
方法
DisposeManaged
protected override void DisposeManaged()
csvFileReader.DisposeManaged()
Disposes the managed resources. Override this method to add custom clean up of managed resources.
ReadRowAsync
public ValueTask<bool> ReadRowAsync(List<string> columns, CancellationToken cancellationToken)
result = csvFileReader.ReadRowAsync(columns, cancellationToken)
Asynchronously reads a row of columns from the current CSV file. Returns false if no more data could be read because the end of the file was reached.
- columns
- Collection to hold the columns read
- cancellationToken
- CancellationToken
返回值: Task