Table of Contents

Class CsvParser

Namespace
FemDesign.Results
Assembly
FemDesign.Core.dll

CSV reader. Reads a comma (or other char) delimited file, line by line and parses each line to a new object. Header lines can be handled with the HeaderParser.

public class CsvParser : IDisposable
Inheritance
CsvParser
Implements
Derived
Inherited Members
Extension Methods

Constructors

CsvParser(string, char, Func<string[], CsvParser, Dictionary<string, string>, object>, Func<string, CsvParser, bool>)

protected CsvParser(string filePath, char delimiter = ',', Func<string[], CsvParser, Dictionary<string, string>, object> rowParser = null, Func<string, CsvParser, bool> headerParser = null)

Parameters

filePath string
delimiter char
rowParser Func<string[], CsvParser, Dictionary<string, string>, object>
headerParser Func<string, CsvParser, bool>

Fields

Header

Last header row read by the header parser.

protected string Header

Field Value

string

HeaderData

protected Dictionary<string, string> HeaderData

Field Value

Dictionary<string, string>

HeaderParser

Returns a boolean representing wether the current line is a Header.

protected Func<string, CsvParser, bool> HeaderParser

Field Value

Func<string, CsvParser, bool>

RowParser

Parses a split line to a new object. Applied on every line not a header.

protected Func<string[], CsvParser, Dictionary<string, string>, object> RowParser

Field Value

Func<string[], CsvParser, Dictionary<string, string>, object>

Stream

public StreamReader Stream

Field Value

StreamReader

Properties

CanPeek

public bool CanPeek { get; }

Property Value

bool

Delimiter

public char Delimiter { get; }

Property Value

char

FilePath

public string FilePath { get; }

Property Value

string

IsDone

public bool IsDone { get; }

Property Value

bool

Methods

AfterParse<T>(List<T>)

protected virtual List<T> AfterParse<T>(List<T> parsed)

Parameters

parsed List<T>

Returns

List<T>

Type Parameters

T

BeforeParse(Type)

protected virtual void BeforeParse(Type type)

Parameters

type Type

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources

public void Dispose()

ParseAll<T>(bool, bool)

public List<T> ParseAll<T>(bool skipNull = true, bool breakOnNull = false)

Parameters

skipNull bool
breakOnNull bool

Returns

List<T>

Type Parameters

T

ParseRow<T>()

protected T ParseRow<T>()

Returns

T

Type Parameters

T

PeekLine()

Returns the next line to be read without consuming it, thus it will still be read by ReadLine.

protected string PeekLine()

Returns

string

PeekNextLine()

Returns the next line that has not already been peeked. The line will not be consumed but still will be read by ReadLine.

protected string PeekNextLine()

Returns

string

ReadRow()

protected string[] ReadRow()

Returns

string[]