Class CSV
IO Utility class for loading time-series data from a plain text comma-separated variable(CSV) file
Inherited Members
Namespace: TimeSeriesAnalysis.Utility
Assembly: TimeSeriesAnalysis.dll
Syntax
public class CSV
Methods
| Edit this page View SourceLoadDataFromCSV(string, char, out double[,], out string[], out string[,])
Load time-series data from a CSV-file, low-level version for further processing
Declaration
public static bool LoadDataFromCSV(string filename, char separator, out double[,] doubleData, out string[] variableNames, out string[,] stringData)
Parameters
Type | Name | Description |
---|---|---|
string | filename | path of file to be loaded |
char | separator | separator character used to separate data in file |
double[,] | doubleData | (output) the returned 2D array where each column is the data for one variable(NaNs if not able to parse as number) |
string[] | variableNames | (output) an array of the variable names in |
string[,] | stringData | (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
Type | Description |
---|---|
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)
Declaration
public static bool LoadDataFromCSV(string filename, out double[,] doubleData, out string[] variableNames, out string[,] stringData)
Parameters
Type | Name | Description |
---|---|---|
string | filename | path of file to be loaded |
double[,] | doubleData | (output) the returned 2D array where each column is the data for one variable |
string[] | variableNames | (output) an array of the variable names in |
string[,] | stringData | (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
Type | Description |
---|---|
bool |
LoadDataFromCsvAsTimeSeries(string, char, out DateTime[], out Dictionary<string, double[]>, string)
Loads data from a CSV-file, including parsing the times(first column)
Declaration
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
Type | Name | Description |
---|---|---|
string | filename | |
char | separator | |
DateTime[] | dateTimes | |
Dictionary<string, double[]> | variables | |
string | dateTimeFormat |
Returns
Type | Description |
---|---|
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
Declaration
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
Type | Name | Description |
---|---|---|
CsvContent | csvString | |
char | separator | |
DateTime[] | dateTimes | |
Dictionary<string, double[]> | variables | |
string | dateTimeFormat |
Returns
Type | Description |
---|---|
bool |
LoadStringsFromCSV(string, out string[,])
Return just string data from a CSV(useful if data contains no numerical data)
Declaration
public static bool LoadStringsFromCSV(string filename, out string[,] stringData)
Parameters
Type | Name | Description |
---|---|---|
string | filename | |
string[,] | stringData |
Returns
Type | Description |
---|---|
bool |
RobustParseDouble(string, out double)
Loading string data into a double value.
Declaration
public static bool RobustParseDouble(string str, out double value)
Parameters
Type | Name | Description |
---|---|---|
string | str | the string to be parsed |
double | value | (output) is the value of the parsed double(if successfully parsed) |
Returns
Type | Description |
---|---|
bool | The method returns true if succesful, otherwise it returns false. |