3.0.2 • Published 2 years ago

@runnerty/executor-csv2json v3.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

NPM version Downloads Dependency Status

Executor for Runnerty: CSV2JSON

Installation:

Through NPM

npm i @runnerty/executor-csv2json

You can also add modules to your project with runnerty-cli

npx runnerty-cli add @runnerty/executor-csv2json

This command installs the module in your project, adds example configuration in your config.json and creates an example plan of use.

If you have installed runnerty-cli globally you can include the module with this command:

rty add @runnerty/executor-csv2json

Configuration sample:

Add in config.json:

{
  "id": "csv2json_default",
  "type": "@runnerty-executor-csv2json"
}

Plan sample:

Add in plan.json:

Example 1:

{
  "id": "csv2json_default",
  "inputPath": "test.csv",
  "outputPath": "test.json",
  "options": {
    "headers": true,
    "delimiter": ";",
    "escape": "\""
  }
}

Example 2:

{
  "id": "csv2json_default",
  "inputPath": "test.csv",
  "options": {
    "headers": ["id_renamed", null, "email"],
    "renameHeaders": true,
    "discardUnmappedColumns": true,
    "delimiter": "|"
  }
}

Params

Options

OptionDescription
delimiterThe delimiter that will separate columns. Default: ','
quoteThe character to use to quote fields that contain a delimiter. Default: '"'
escapeThe character to used tp escape quotes inside of a quoted field. Default: '"'
headersIf set to true the first row will be treated as the headers. If you want to manually specify the headers set to a string[]. Default: true
renameHeadersIf you want the first line of the file to be removed and replaced by the one provided in the headers option. Default: false
ignoreEmptySet to true to ignore empty rows. Default: false
commentIf your CSV contains comments you can use this option to ignore lines that begin with the specified character. Default: null
discardUnmappedColumnsIf you want to discard columns that do not map to a header. Default: false
strictColumnHandlingIf you want to consider empty lines/lines with too few fields as invalid and emit a data-invalid event. Default: false
trimSet to true to trim all white space from columns. Default: false
rtrimSet to true to right trim all columns. Default: false
ltrimSet to true to left trim all columns. Default: false
encodingPassed to StringDecoder when decoding incoming buffers. Change if incoming content is not 'utf8' encoded. Default: 'utf8'
maxRowsIf number is > 0 then only the specified number of rows will be parsed. Default: 0
skipRowsIf number is > 0 then the specified number of parsed rows will be skipped. Default: 0
skipLinesIf number is > 0 the specified number of lines will be skipped. Default: 0

Output (Process values):

  • PROCESS_EXEC_MSG_OUTPUT: Output message.
  • PROCESS_EXEC_ERR_OUTPUT: Error output message.

Data output

  • PROCESS_EXEC_DATA_OUTPUT: JSON output data.
  • PROCESS_EXEC_DB_ROWCOUNT: Count rows.

More information:

This executor uses the fast-csv module, for more information consult the website of the csv2json.