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
filenamestringpath of file to be loaded
separatorcharseparator character used to separate data in file
doubleDatadouble[,](output) the returned 2D array where each column is the data for one variable(NaNs if not able to parse as number)
variableNamesstring[](output) an array of the variable names in
doubleDatastringDatastring[,](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
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
filenamestringpath of file to be loaded
doubleDatadouble[,](output) the returned 2D array where each column is the data for one variable
variableNamesstring[](output) an array of the variable names in
doubleDatastringDatastring[,](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
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
filenamestringseparatorchardateTimesDateTime[]variablesDictionary<string, double[]>dateTimeFormatstring
Returns
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
csvStringCsvContentseparatorchardateTimesDateTime[]variablesDictionary<string, double[]>dateTimeFormatstring
Returns
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
Returns
RobustParseDouble(string, out double)
Loading string data into a double value.
public static bool RobustParseDouble(string str, out double value)
Parameters
strstringthe string to be parsed
valuedouble(output) is the value of the parsed double(if successfully parsed)
Returns
- bool
The method returns true if succesful, otherwise it returns false.