new csv-string-optimization()
CSV String Optimization
Strongly inspired by OpenRefine
https://github.com/OpenRefine/OpenRefine
Methods
(static) cleanFile(data, template, column_name) → {object}
Use a template to clean a file
Parameters:
Name | Type | Description |
---|---|---|
data |
array | array of objects to be cleaned. |
template |
object | Template (parsed JSON). |
column_name |
string | Column name of data to be cleaned. |
Returns:
parsed data.
- Type
- object
(static) dsv(file, delimiter) → {object}
Load a delimiter separated file.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | Path to file. |
delimiter |
string | default:",". |
Returns:
parsed file.
- Type
- object
(static) extractColumn(data, column_name) → {array}
Extract column from object array
Parameters:
Name | Type | Description |
---|---|---|
data |
array | array of objects. |
column_name |
string | name of to be extracted column. |
Returns:
column.
- Type
- array
(static) jfy(str) → {object}
Shorthand for JSON.stringify.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | to be parsed string |
Returns:
parsed string.
- Type
- object
(static) json(file) → {object}
Load a JSON file.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | Path to file. |
Returns:
parsed file.
- Type
- object
(static) mergeTemplate(oldTemplate, newTemplate) → {object}
Merge two templates created with this module.
Parameters:
Name | Type | Description |
---|---|---|
oldTemplate |
object | Old template as parsed json. |
newTemplate |
object | New template as parsed json. |
Returns:
merged template.
- Type
- object
(static) niceFormatting(json) → {string}
Transfor json into a nice to read and edit file.
Parameters:
Name | Type | Description |
---|---|---|
json |
json | to be formatted. |
Returns:
ready to be written to a file.
- Type
- string
(static) save(path, data) → {Void}
Save a file.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to destination file. |
data |
string | To be written to file. |
Returns:
- .
- Type
- Void
(static) saveCsv(path, data, separator) → {Void}
Save object to CSV file
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to file. |
data |
array | array of objects to be save to CSV. |
separator |
string | default:",". |
Returns:
- .
- Type
- Void
(static) saveJson(path, data) → {Void}
Stringify and save JSON
Parameters:
Name | Type | Description |
---|---|---|
path |
string | Path to file. |
data |
object | JSON content. |
Returns:
- .
- Type
- Void