Table of Contents

Class CSV

Namespace
TimeSeriesAnalysis.Utility
Assembly
TimeSeriesAnalysis.dll

IO Utility class for loading time-series data from a plain text comma-separated variable(CSV) file

public class CSV
Inheritance
CSV
Inherited Members

Methods

LoadDataFromCSV(string, char, out double[,], out string[], out string[,])

Load time-series data from a CSV-file, low-level version for further processing

public static bool LoadDataFromCSV(string filename, char separator, out double[,] doubleData, out string[] variableNames, out string[,] stringData)

Parameters

filename string

path of file to be loaded

separator char

separator character used to separate data in file

doubleData double[,]

(output) the returned 2D array where each column is the data for one variable(NaNs if not able to parse as number)

variableNames string[]

(output) an array of the variable names in doubleData

stringData string[,]

(output)the raw data of the entire csv-file in a 2D array, only needed if parsing of other two variables has failed, and useful for retireving timestamps

Returns

bool

LoadDataFromCSV(string, out double[,], out string[], out string[,])

Load time-series data from a CSV-file into variables for further processing (using the default ";" separator)

public static bool LoadDataFromCSV(string filename, out double[,] doubleData, out string[] variableNames, out string[,] stringData)

Parameters

filename string

path of file to be loaded

doubleData double[,]

(output) the returned 2D array where each column is the data for one variable

variableNames string[]

(output) an array of the variable names in doubleData

stringData string[,]

(output)the raw data of the entire csv-file in a 2D array, only needed if parsing of other two variables has failed, and useful for retireving timestamps

Returns

bool

LoadDataFromCsvAsTimeSeries(string, char, out DateTime[], out Dictionary<string, double[]>, string)

Loads data from a CSV-file, including parsing the times(first column)

public static bool LoadDataFromCsvAsTimeSeries(string filename, char separator, out DateTime[] dateTimes, out Dictionary<string, double[]> variables, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss")

Parameters

filename string
separator char
dateTimes DateTime[]
variables Dictionary<string, double[]>
dateTimeFormat string

Returns

bool

LoadDataFromCsvContentAsTimeSeries(CsvContent, char, out DateTime[], out Dictionary<string, double[]>, string)

Version of LoadDataFromCSV that accepts a CSVcontent containting the contents of a CSV-file as input

public static bool LoadDataFromCsvContentAsTimeSeries(CsvContent csvString, char separator, out DateTime[] dateTimes, out Dictionary<string, double[]> variables, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss")

Parameters

csvString CsvContent
separator char
dateTimes DateTime[]
variables Dictionary<string, double[]>
dateTimeFormat string

Returns

bool

LoadStringsFromCSV(string, out string[,])

Return just string data from a CSV(useful if data contains no numerical data)

public static bool LoadStringsFromCSV(string filename, out string[,] stringData)

Parameters

filename string
stringData string[,]

Returns

bool

RobustParseDouble(string, out double)

Loading string data into a double value.

public static bool RobustParseDouble(string str, out double value)

Parameters

str string

the string to be parsed

value double

(output) is the value of the parsed double(if successfully parsed)

Returns

bool

The method returns true if succesful, otherwise it returns false.