Table of Contents

Class Csv

Namespace
EpNet.Results
Assembly
EpNet.dll

Provides methods for reading or saving data in csv format.

public static class Csv
Inheritance
Csv

Methods

GetColumns(string)

Gets a Dictionary from a csv with Keys as column headers and Values as List of column numeric values. List separator (,) and decimal point (.) are those from Invariant Culture.

public static Dictionary<string, List<double>> GetColumns(string file)

Parameters

file string

Absolute path to the file.

Returns

Dictionary<string, List<double>>

A Dictionary with Keys from the first column and Values as a list of values from the rest of the columns

GetColumns(string, CultureInfo)

Gets a Dictionary from a csv with Keys as column headers and Values as List of column numeric values.

public static Dictionary<string, List<double>> GetColumns(string file, CultureInfo culture)

Parameters

file string

Absolute path to the file.

culture CultureInfo

Speficied culture info.

Returns

Dictionary<string, List<double>>

A Dictionary with Keys from the first column and Values as a list of values from the rest of the columns

GetColumns<T>(string)

Gets a Dictionary from a csv with Keys as column headers and Values as List of T with column values.List separator (,) and decimal point (.) are those from Invariant Culture.

public static Dictionary<string, List<T>> GetColumns<T>(string file)

Parameters

file string

Absolute path to the file.

Returns

Dictionary<string, List<T>>

A Dictionary with Keys from the first column and Values as a list of values from the rest of the columns

Type Parameters

T

string or double

GetColumns<T>(string, CultureInfo)

Gets a Dictionary from a csv with Keys as column headers and Values as List of T with column values.

public static Dictionary<string, List<T>> GetColumns<T>(string file, CultureInfo culture)

Parameters

file string

Absolute path to the file.

culture CultureInfo

Speficied culture info.

Returns

Dictionary<string, List<T>>

A Dictionary with Keys from the first column and Values as a list of values from the rest of the columns

Type Parameters

T

string or double

GetData(string, CultureInfo, int, int)

Gets a Dictionary from a csv file with a specified column as string Keys and a specified column as numeric Values. List separator and decimal point are those from a specified Culture.

public static Dictionary<string, double> GetData(string file, CultureInfo culture, int col1 = 0, int col2 = 1)

Parameters

file string

Absolute path to the file.

culture CultureInfo

Speficied culture info.

col1 int

Column for generating the Keys

col2 int

Column for generating the Values

Returns

Dictionary<string, double>

A Dictionary with Keys from column 1 and Values from column 2

GetData(string, int, int)

Gets a Dictionary from a csv file with a specified column as string Keys and a specified column as numeric Values. List separator (,) and decimal point (.) are those from Invariant Culture.

public static Dictionary<string, double> GetData(string file, int col1 = 0, int col2 = 1)

Parameters

file string

Absolute path to the file.

col1 int

Column for generating the Keys

col2 int

Column for generating the Values

Returns

Dictionary<string, double>

A Dictionary with Keys from column 1 and Values from column 2

GetData<T>(string, CultureInfo, int, int)

Gets a Dictionary from a csv file with a specified column as string Keys and a specified column as T Values. List separator and decimal point are those from a specified Culture.

public static Dictionary<string, T> GetData<T>(string file, CultureInfo culture, int col1 = 0, int col2 = 1)

Parameters

file string

Absolute path to the file.

culture CultureInfo

Speficied culture info.

col1 int

Column for generating the Keys

col2 int

Column for generating the Values

Returns

Dictionary<string, T>

A Dictionary with Keys from column 1 and Values from column 2

Type Parameters

T

double or string

GetData<T>(string, int, int)

Gets a Dictionary from a csv file with a specified column as string Keys and a specified column as T Values. List separator (,) and decimal point (.) are those from Invariant Culture.

public static Dictionary<string, T> GetData<T>(string file, int col1 = 0, int col2 = 1)

Parameters

file string

Absolute path to the file.

col1 int

Column for generating the Keys

col2 int

Column for generating the Values

Returns

Dictionary<string, T>

A Dictionary with Keys from column 1 and Values from column 2

Type Parameters

T

double or string

GetRows(string)

Gets a Dictionary from a csv file with the first column as string Keys and the Values with rest of columns as lists of numbers. List separator (,) and decimal point (.) are those from Invariant Culture.

public static Dictionary<string, List<double>> GetRows(string file)

Parameters

file string

Absolute path to the file.

Returns

Dictionary<string, List<double>>

A Dictionary with Keys from the first column and Values as a list of numbers from the rest of the columns

GetRows(string, CultureInfo)

Gets a Dictionary from a csv file with the first column as string Keys and the Values with rest of columns as lists of numbers. List separator and decimal point are those from a specified Culture.

public static Dictionary<string, List<double>> GetRows(string file, CultureInfo culture)

Parameters

file string

Absolute path to the file.

culture CultureInfo

Speficied culture info.

Returns

Dictionary<string, List<double>>

A Dictionary with Keys from the first column and Values as a list of numbers from the rest of the columns

GetRows<T>(string)

Gets a Dictionary from a csv file with the first column as string Keys and the Values with rest of columns as lists of T. List separator (,) and decimal point (.) are those from Invariant Culture.

public static Dictionary<string, List<T>> GetRows<T>(string file)

Parameters

file string

Absolute path to the file.

Returns

Dictionary<string, List<T>>

A Dictionary with Keys from the first column and Values as a list of values from the rest of the columns

Type Parameters

T

string or double

GetRows<T>(string, CultureInfo)

Gets a Dictionary from a csv file with the first column as string Keys and the Values with rest of columns as lists of T. List separator and decimal point are those from a specified Culture.

public static Dictionary<string, List<T>> GetRows<T>(string file, CultureInfo culture)

Parameters

file string

Absolute path to the file.

culture CultureInfo

Speficied culture info.

Returns

Dictionary<string, List<T>>

A Dictionary with Keys from the first column and Values as a list of values from the rest of the columns.

Type Parameters

T

string or double

Save(string, IDictionary<string, double>, bool)

Creates a text file and writes sequentially a dictionary as a string column (Key) and a numeric column (Value).

public static void Save(string file, IDictionary<string, double> data, bool append = false)

Parameters

file string

Absolute path to the file.

data IDictionary<string, double>

Dictionary of string and numeric data.

append bool

true for appending to an existing file.

Save(string, IDictionary<string, string>, bool)

Creates a text file and writes sequentially a dictionary as two a string columns (Key and Value).

public static void Save(string file, IDictionary<string, string> data, bool append = false)

Parameters

file string

Absolute path to the file.

data IDictionary<string, string>

Dictionary of string Keys and Values.

append bool

true for appending to an existing file.

Save(string, IEnumerable<IEnumerable<double>>)

Creates a text file and writes sequentially a list of list data.

public static void Save(string file, IEnumerable<IEnumerable<double>> data)

Parameters

file string

Absolute path to the file.

data IEnumerable<IEnumerable<double>>

Data list of numeric lists

Save(string, IEnumerable<IEnumerable<string>>)

Creates a text file and writes sequentially a list of list data.

public static void Save(string file, IEnumerable<IEnumerable<string>> data)

Parameters

file string

Absolute path to the file.

data IEnumerable<IEnumerable<string>>

Data list of string lists

Save(string, IEnumerable<double>, bool)

Creates a text file and writes sequentially a list of numeric data.

public static void Save(string file, IEnumerable<double> data, bool append = false)

Parameters

file string

Absolute path to the file.

data IEnumerable<double>

List of numeric data.

append bool

true for appending to an existing file.

Save(string, params IEnumerable<double>[])

Creates a text file and writes sequentially a list of numeric data.

public static void Save(string file, params IEnumerable<double>[] data)

Parameters

file string

Absolute path to the file.

data IEnumerable<double>[]

Data array

Save(string, IEnumerable<string>, bool)

Creates a text file and writes sequentially a list of string data.

public static void Save(string file, IEnumerable<string> data, bool append = false)

Parameters

file string

Absolute path to the file.

data IEnumerable<string>

List of string data.

append bool

true for appending to an existing file.

Save(string, params IEnumerable<string>[])

Creates a text file and writes sequentially a list of text strings.

public static void Save(string file, params IEnumerable<string>[] data)

Parameters

file string

Absolute path to the file.

data IEnumerable<string>[]

Data array