# countChar(str, c)
This function counts the times a char is found in a string
Parameters
Name | Types | Description |
---|---|---|
str | String |
This is the text to be searched in |
c | Char |
This is the single text character to search |
Returns
Number
Returns a number of found matches
# csvToArray(csv, options)
This function parses a CSV string into an array structur Given a second paramter options of type object, default options can be overriden * fSep
defaults to ';' or ',' (depending on what character is found more often) * rSep
defaults to '\n', '\r' or '\r\n' (depending on auto detection mechanism) * quot
defaults to '"' * head
defaults to false and allows ignoring the first row * trim
defaults to false
Parameters
Name | Types | Description |
---|---|---|
csv | String |
This is the text to consider as CSV |
options | Object |
This object can be used to override defaults |
Returns
Array
Returns an array of rows with nested arrays of field data
# csvToArrayByKey(csv, key, options)
This function parses a CSV string into an array structur while reducing the return to a shallow list with a single column of data
Parameters
Name | Types | Description |
---|---|---|
csv | String |
This is the text to consider as CSV |
key | String |
Number |
options | Object |
This object can be used to override defaults |
Returns
Array
Returns an array data from the requested column
# csvToObject(csv, options)
This function uses csvToArray (see function description), but converts the basic array into an object with keys based on the header. Because that is the case the removeHead option cannot be overriden and a header should be present in the CSV for text to work properly.
Parameters
Name | Types | Description |
---|---|---|
csv | String |
This is the text to consider as CSV |
options | Object |
This object can be used to override defaults |
Returns
Array
Returns an array of rows with nested objects containing named fields
# csvToObjectByKey(csv, key, options)
Parse a CSV file into an object grouped by the specified key, containing each an array of rows of nested objects with named cells (key and value). If a specific object key only has a single member, the object is directly listed without being nested in an array. The behavior of this function can be modified by specifying the value of options.objectByKeyMode
: * auto
(default) - this setting parses each nested key into a direct object, but converts it into a list if multiple elements by the key are found * list
- this setting always forces a nested array listing. Hence, even single entries by the specified key will result in a nested array * reduce
- this function never creates a nested list and multiple entries by a specified key overwrite each other and the last occurrence prevails
Parameters
Name | Types | Description |
---|---|---|
csv | String |
This is the text to consider as CSV |
key | String |
Number |
options | Object |
This object can be used to override defaults |
Returns
Object
Returns an object with named keys with nested objects containing named fields
# getLineBreakChar(str)
This function determines the line endings used in a string
Parameters
Name | Types | Description |
---|---|---|
str | String |
This is the text to inspect |
Returns
Number
Returns the used line ending type
# getTables(text, convert, options)
This function splits a string containing multiple CSV/TSV tables and returns an object of string or if optionaly into a data format
Parameters
Name | Types | Description |
---|---|---|
text | String |
This is the text (either TSV or CSV) containing the tables |
convert | Boolean |
If this boolean is set to true table is directly converted else it is kept as a string |
options | Object |
This object can be used to override defaults and is only used if conversion is enabled |
Returns
Object
Returns an object with tables referenced by index and if provided also by sheet and table name
# HypeDataParser()
# includesTables(str)
This function determines if a string most likely contains multiple tables (very simple check)
Parameters
Name | Types | Description |
---|---|---|
str | String |
This is the text to inspect |
Returns
Boolean
Returns if the provided text contains multiple tables
# rowsToColumns(csv, options)
This function transposes rows to columns as long as the length of the inital row is the same
Parameters
Name | Types | Description |
---|---|---|
csv | String |
This is the text to consider as CSV |
options | Object |
This object can be used to override defaults |
Returns
Array
Returns an array of rows transposed to columns
# tsvToArrayByKey()
This is an alias to the TSV version of the csvToArrayByKey method. The only difference being that the field separator (fSep) is set to tab (\t). Please look at the documentation for csvToArrayByKey
# tsvToObjectByKey()
This is an alias to the TSV version of the csvToObjectByKey method. The only difference being that the field separator (fSep) is set to tab (\t). Please look at the documentation for csvToObjectByKey