Table of Contents

Class CSVReader

Namespace
NominalSystems.Universe
Assembly
NominalSystems.Universe.dll

This class is a helper to read CSV files in an array and be able to pull records based on elements in the table if they exist.

public class CSVReader
Inheritance
CSVReader

Constructors

CSVReader(string, char)

Initialises the data from a CSV file and loads it into the data list for retrieval.

public CSVReader(string file, char delimiter = ',')

Parameters

file string

The full path to the file.

delimiter char

The delimiting character for each cell.

Fields

IsValid

A flag for if the file exists or if it is invalid. If the path is wrong, then this flag will be False.

public bool IsValid

Field Value

bool

Properties

Rows

The number of rows that exist in the CSV file

public int Rows { get; }

Property Value

int

Methods

FindRowWhere(string, char, double, int)

Attempts to find the first row where a particular condition is met. This could be <, = or >.

public int FindRowWhere(string header, char operation = '=', double value = 0, int decimals = 6)

Parameters

header string

The name of the column to look through

operation char

The operation to use: <, = or >

value double

The value to compare to

decimals int

The number of decimal places to track

Returns

int

The index of the row that exists. A -1 will be returned if it does not find.

GetAllDoubleData()

Returns all data as a list of doubles

public List<List<double>> GetAllDoubleData()

Returns

List<List<double>>

A list of all double data

GetDouble(int, int)

Gets an double value from the CSV based on a coodinate from the CSV file. If no data exists, then it will return a 0.0.

public double GetDouble(int row, int col)

Parameters

row int

The row index

col int

The column index

Returns

double

The data value as a double if it exists

GetDouble(string, int)

Gets an double value from the CSV based on a coodinate from the CSV file. If no data exists, then it will return a 0.0.

public double GetDouble(string column, int row)

Parameters

column string

The name of the column

row int

The row index

Returns

double

The data value as a double if it exists

GetFloat(int, int)

Gets an floating point value from the CSV based on a coodinate from the CSV file. If no data exists, then it will return a 0.0.

public float GetFloat(int row, int col)

Parameters

row int

The row index

col int

The column index

Returns

float

The data value as a float if it exists

GetInt(int, int)

Gets an integer value from the CSV based on a coodinate from the CSV file. If no data exists, then it will return a 0.

public int GetInt(int row, int col)

Parameters

row int

The row index

col int

The column index

Returns

int

The data value as a int if it exists

GetString(int, int)

Gets a string from the column based on a coordinate from the CSV file. If no data exists, then it will return a null value.

public string GetString(int row, int col)

Parameters

row int

The row index

col int

The column index

Returns

string

The string data if it exists

GetVector3(string, int)

Gets a Vector3 from the CSV based on the column name. This assumes that the column entered is the first and the other two columns are right next to each other.

public Vector3 GetVector3(string columnX, int row)

Parameters

columnX string

The name of the first column to look for

row int

The row index

Returns

Vector3

The Vector data from that row at that column

HasColumn(string)

Returns whether a particular column exists.

public bool HasColumn(string column)

Parameters

column string

The name of the column

Returns

bool

A flag for if the column exists