IGLib
1.7.2
The IGLib base library for development of numerical, technical and business applications.
|
Auxiliary utilities for dealing with files in CSV and other delimited formats. More...
Static Public Member Functions | |
static bool | CsvIsEmptyRow (string[][] values, int rowIndex) |
Returns true if the specified line in a 2D jagged array of string cell values (arranged in rows) is empty or does not exist, otherwise false is returned. More... | |
static string | CsvGetValue (string[][] values, int rowIndex, int columnIndex) |
Returns the value of the specified cell of a 2D jagged array of string cell values (arranged in rows) at the specified row and column, or null if such a value does not exist. More... | |
static int | CsvColumnIndex (string[][] values, string fieldName) |
Returns index of thr column that contains data with the specified name in a 2D jagged array of values. It is assumed that the first non-empty row (subarray) contains names of data columns. -1 is returned if the column with the specified field name is not found. Column (or field) names are assumed to be case insensitive. More... | |
static int | CsvColumnIndex (string[][] values, string fieldName, bool caseSensitive) |
Returns index of thr column that contains data with the specified name in a 2D jagged array of values. It is assumed that the first non-empty row (subarray) contains names of data columns. -1 is returned if the column with the specified field name is not found. More... | |
static string[][] | FromCsvString (string csvString) |
Converts a CSV string to a 2D jagged array of string values and returns it. Constant UtilCsv.DefaultCsvSeparator) is assumed to be a separator in the CSV format. More... | |
static string[][] | FromCsvString (string csvString, string separator) |
Converts a CSV string to a 2D jagged array of string values and returns it. More... | |
static string | ToCsvString (string[][] values, string separator) |
Convertsa a 2D jagged array of string values to a string in CSV format. More... | |
static string[][] | LoadCsv (string filePath, string separator) |
Reads contents of a CSV file and returns a 2D jagged array of strigg values contained in the file. More... | |
static string[][] | LoadCsv (string filePath) |
Reads contents of a CSV file and returns a 2D jagged array of strigg values contained in the file. Constant UtilCsv.DefaultCsvSeparator is assumed as separator in the CSV file. More... | |
static void | SaveCsv (string filePath, string[][] values, string separator, bool append) |
Saves a 2D jagged array of string cell values into a CSV file. More... | |
static void | SaveCsv (string filePath, string[][] values, string separator) |
Saves a 2D jagged array of string cell values into a CSV file. If the file already exists then its contents are overwritten. More... | |
static void | SaveCsv (string filePath, string[][] values, bool append) |
Saves a 2D jagged array of string cell values into a CSV file. Constant UtilCsv.DefaultCsvSeparator is assumed to be a separator for the CSV format. More... | |
static void | SaveCsv (string filePath, string[][] values) |
Saves a 2D jagged array of string cell values into a CSV file. If the file already exists then its contents are overwritten. Constant UtilCsv.DefaultCsvSeparator is assumed to be a separator for the CSV format. More... | |
static bool | TestCsvStringConversion (string[][] values, string separator, bool printResults) |
Tests conversion of a 2D jagged array of string values to a CSV formatted string and back. Returns true if the array restored by conversion of the original array to a CSV string and back from a CSV string to a jagged array is the same (within inevitable ambiguities of the CSV format) as the original array. More... | |
static void | ExampleCsv () |
Example of using CSV format utilities. More... | |
Public Attributes | |
const string | DefaultCsvSeparator = "," |
The default separator in the CSV files - comma (","). More... | |
Static Public Attributes | |
static string | _csvSeparator = DefaultCsvSeparator |
Static Protected Member Functions | |
static string | TableToString (string[][] values, string valueSeparator) |
Returns a string that represents a table of string values. Each value is embedded in double quotes, values are separated by commas, and tables of values are separated by newlines. More... | |
Properties | |
static string | CsvSeparator [get, set] |
Auxiliary utilities for dealing with files in CSV and other delimited formats.
CSV - related utilities were moved here from the UtilStr class on May 2013.
$A Igor xx May13;
|
inlinestatic |
Returns true if the specified line in a 2D jagged array of string cell values (arranged in rows) is empty or does not exist, otherwise false is returned.
values | A 2D jagged array that contains a table of tables (rows) of string cell values. Such array corresponds a table of rows of cells stored in CSV format. |
rowIndex | Index of the line that is tested for being empty or not. |
$A Igor Oct08;
|
inlinestatic |
Returns the value of the specified cell of a 2D jagged array of string cell values (arranged in rows) at the specified row and column, or null if such a value does not exist.
values | A 2D jagged array that contains a table of tables (rows) of string cell values. Such array corresponds a table of rows of cells stored in CSV format. |
rowIndex | Row number. |
columnIndex | Column number. |
$A Igor Oct08;
|
inlinestatic |
Returns index of thr column that contains data with the specified name in a 2D jagged array of values. It is assumed that the first non-empty row (subarray) contains names of data columns. -1 is returned if the column with the specified field name is not found. Column (or field) names are assumed to be case insensitive.
values | A 2D jagged array that contains a table of tables (rows) of string cell values. Such array corresponds a table of rows of cells stored in CSV format. |
fieldName | Name of the data column (field) whose column index is searched for. |
$A Igor Oct08;
|
inlinestatic |
Returns index of thr column that contains data with the specified name in a 2D jagged array of values. It is assumed that the first non-empty row (subarray) contains names of data columns. -1 is returned if the column with the specified field name is not found.
values | A 2D jagged array that contains a table of tables (rows) of string cell values. Such array corresponds a table of rows of cells stored in CSV format. |
fieldName | Name of the data column (field) whose column index is searched for. |
caseSensitive | Whether column (field) names are case sensitive or not. |
$A Igor Oct08;
|
inlinestatic |
Converts a CSV string to a 2D jagged array of string values and returns it. Constant UtilCsv.DefaultCsvSeparator) is assumed to be a separator in the CSV format.
csvString | A CSV string representing data in CSV format. |
$A Igor Oct08;
|
inlinestatic |
Converts a CSV string to a 2D jagged array of string values and returns it.
csvString | A CSV string representing data in CSV format. |
separator | Separator that is used in CSV format (usually , or ;). If null or empty string then Constant UtilCsv.DefaultCsvSeparator is taken. |
$A Igor Oct08;
|
inlinestatic |
Convertsa a 2D jagged array of string values to a string in CSV format.
values | dD table of string values that are written in CSV format. |
separator | Separator that is used to separate cell values. If null or empty string then Constant UtilCsv.DefaultCsvSeparator is taken. |
If the value of any cell contains separators then it is embedded in double quotes.
$A Igor Oct08;
Referenced by IG.Lib.StringTable.ToString().
|
inlinestaticprotected |
Returns a string that represents a table of string values. Each value is embedded in double quotes, values are separated by commas, and tables of values are separated by newlines.
values | a 2D jagged array of string values that is converted to a string. |
valueSeparator | Separator that separates individual values in a row. If not specified then Constant UtilCsv.DefaultCsvSeparator is taken. |
$A Igor Oct08;
|
inlinestatic |
Reads contents of a CSV file and returns a 2D jagged array of strigg values contained in the file.
filePath | Path to the CSV file that is read and parsed. |
separator | Separator that is used in the CSV file. If not specified (null or empty string) then Constant UtilCsv.DefaultCsvSeparator is assumed. |
$A Igor Oct08;
References IG.Lib.UtilStr.Load().
Referenced by IG.Lib.StringTable.LoadCsv(), and IG.Num.VectorBase.LoadCsv().
|
inlinestatic |
Reads contents of a CSV file and returns a 2D jagged array of strigg values contained in the file. Constant UtilCsv.DefaultCsvSeparator is assumed as separator in the CSV file.
filePath | Path to the CSV file that is read and parsed. |
$A Igor Oct08;
|
inlinestatic |
Saves a 2D jagged array of string cell values into a CSV file.
filePath | Path to the file into which contents is written. |
values | A 2D jagged array of string cell values. Each outer element contains one row of values in CSV. |
separator | Separator that is used in CSV format. |
append | If true then the CSV string is appended to the existent file if the file already exists. Otherwise, existend files are overwritten. |
References IG.Lib.UtilStr.Save().
Referenced by IG.Lib.StringTable.SaveCsv(), and IG.Num.VectorBase.SaveCsv().
|
inlinestatic |
Saves a 2D jagged array of string cell values into a CSV file. If the file already exists then its contents are overwritten.
filePath | Path to the file into which contents is written. |
values | A 2D jagged array of string cell values. Each outer element contains one row of values in CSV. |
separator | Separator that is used in CSV format. |
$A Igor Oct08;
|
inlinestatic |
Saves a 2D jagged array of string cell values into a CSV file. Constant UtilCsv.DefaultCsvSeparator is assumed to be a separator for the CSV format.
filePath | Path to the file into which contents is written. |
values | A 2D jagged array of string cell values. Each outer element contains one row of values in CSV. |
append | If true then the CSV string is appended to the existent file if the file already exists. Otherwise, existend files are overwritten. |
|
inlinestatic |
Saves a 2D jagged array of string cell values into a CSV file. If the file already exists then its contents are overwritten. Constant UtilCsv.DefaultCsvSeparator is assumed to be a separator for the CSV format.
filePath | Path to the file into which contents is written. |
values | A 2D jagged array of string cell values. Each outer element contains one row of values in CSV. |
$A Igor Oct08;
|
inlinestatic |
Tests conversion of a 2D jagged array of string values to a CSV formatted string and back. Returns true if the array restored by conversion of the original array to a CSV string and back from a CSV string to a jagged array is the same (within inevitable ambiguities of the CSV format) as the original array.
values | Original 2D jagged array of values arranged by rows, which is converted to a CSV string and back. |
separator | Separator that is used in CSV format (usually this will be "," or ";", sometimes "\t"). If not specified (null or empty string) then the Constant UtilCsv.DefaultCsvSeparator is assumed. |
printResults | If true then detailed results of the test are printed to a console, indicating all individual differences between the original and restored data. It is also indicated whether the individual differences are considered errors (if not then a string describing a difference begins with "WARNING"). |
|
inlinestatic |
Example of using CSV format utilities.
$A Igor Oct08;
const string IG.Lib.UtilCsv.DefaultCsvSeparator = "," |
The default separator in the CSV files - comma (",").
Referenced by IG.Num.ScalarFunctionScriptControllerBase< ScalarFunctionType >.LoadCsv(), IG.Num.VectorBase.LoadCsv(), IG.Num.ScalarFunctionScriptControllerBase< ScalarFunctionType >.SaveCsv(), and IG.Num.VectorBase.SaveCsv().
|
static |
|
staticgetset |