Table of Contents

Class CsvFileReader

Namespace
Ecng.Common
Assembly
Ecng.Common.dll

Class for reading from comma-separated-value (CSV) files

public class CsvFileReader : CsvFileCommon, IDisposable
Inheritance
CsvFileReader
Implements
Inherited Members
Extension Methods

Constructors

CsvFileReader(Stream, string, EmptyLineBehavior)

Initializes a new instance of the CsvFileReader class for the specified stream.

public CsvFileReader(Stream stream, string lineSeparator, EmptyLineBehavior emptyLineBehavior = EmptyLineBehavior.NoColumns)

Parameters

stream Stream

The stream to read from

lineSeparator string

The line separator to use.

emptyLineBehavior EmptyLineBehavior

Determines how empty lines are handled

CsvFileReader(TextReader, string, EmptyLineBehavior)

Initializes a new instance of the CsvFileReader class for the specified file path.

public CsvFileReader(TextReader reader, string lineSeparator, EmptyLineBehavior emptyLineBehavior = EmptyLineBehavior.NoColumns)

Parameters

reader TextReader

The file reader.

lineSeparator string

The line separator to use.

emptyLineBehavior EmptyLineBehavior

Determines how empty lines are handled

CsvFileReader(string, string, EmptyLineBehavior)

Initializes a new instance of the CsvFileReader class for the specified file path.

public CsvFileReader(string path, string lineSeparator, EmptyLineBehavior emptyLineBehavior = EmptyLineBehavior.NoColumns)

Parameters

path string

The name of the CSV file to read from

lineSeparator string

The line separator to use.

emptyLineBehavior EmptyLineBehavior

Determines how empty lines are handled

Methods

DisposeManaged()

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

protected override void DisposeManaged()

ReadRow(List<string>)

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.

public bool ReadRow(List<string> columns)

Parameters

columns List<string>

Collection to hold the columns read

Returns

bool