Exports the input content to a file.
The File Export Plug-in can output input values of any format to a file. You can use the Apache Velocity Engine VTL (Velocity Template Language) http://velocity.apache.org/ to specify the output format. If no format is specified, the input values are output as-is with no formatting.
The File export plug-in specifies the full-path to the output file, exports the data, and generates error messages if necessary
Prerequisites
- Name and location of the file to export.
- If necessary, prepared template for output format.
Cautionary notes
- If a file has the same name as an existing output file, the former will be overwritten.
- If a folder has the same name as an existing output file, a write error occurs.
- Line feed codes in the export content and output template are included in the output file.
Return codes
The File Export Plug-in generates the following return codes.
Return Code | Description |
---|---|
0 | Ended normally. |
1 | The length of the output file path is longer than 256 characters. |
2 | A grammatical error has been detected in the VTL description. |
3 | This value is returned when an undefined attribute or method is detected in the VTL description. Usually, this value is not returned unless Velocity is run in strict mode. By default, strict mode is set to false. |
4 | The resource file used for Velocity cannot be located. In most cases, this value is not returned since the File Export Plug-in does not use the resource file but is included to accommodate the exception that is generated by the Velocity API. |
5 | An error occurred while writing the output file. |
63 | An error occurred during the processing of the plug-in. |
80 | Task execution has stopped. |
Property list
The following properties are available for the File Export Plug-in:
Property key | Property name | Description | I/O type |
---|---|---|---|
content R | Content To Export | Specifies the content to be exported to the file. | Input |
fileName R | Output File Name | Specifies the name of the file where the content is to be exported. Empty strings are not valid. The length of the full path consisting of the output folder path and the output file name cannot exceed 256 characters. | Input |
directoryPath | Output Directory Path | Folder path where the output file is to be created; an absolute or relative path can be specified. If you specify a relative path, the task working folder (Automation/data/task/[tasked]) is assumed as the starting point for the path. If you do not specify a folder path, the task working folder (Automation/data/task/[tasked]) is used. The length of the full path consisting of the output folder path and the output file name cannot exceed 256 characters. | Input |
template | Template For The Output | Specifies a template with the VTL description that defines the format for the output content. | Input |
charset | Character Set | Specifies the character set for the output file. | Input |
exportFilePath | Output File Path | Specifies the full path for the output file to be exported. | Output |
message | Message | Specifies the log for messages generated during the processing of the plug-in. | Output |
R: Required |
Input values with the output template
Any character can be specified in the input values. If the input values are JSON, the values are JSON decoded as objects via the variable $root in the VTL description of the output template, and the objects can be viewed. If the input values are not JSON, $root keeps the input values as character strings. The description method of the output template complies with the VTL syntax. Note that the variable $root described previously is a reserved variable to which File Export Plug-in specifies values in advance. In addition, File Export Plug-in has a utility for CSV output as a reserved variable $csv. The following table shows the reserved variables that can be used in the VTL description for File Export Plug-in.
Variable name | Description |
---|---|
$root | If an input value is JSON, the value is JSON decoded and stored as an object. If the input value is not JSON, the value is stored as a character string. |
$csv Gives the following utility methods for CSV output. These can be used for the VTL description using Velocity's ToolManager. |
$csv.value(String) -- Takes a single string as an argument; if a character (such as a double quotation mark, comma, or line feed) that needs an escape in CSV is included, enclose the value with double quotation marks. If a double quotation mark is included in a string value, the string in which the double quotation mark is escaped (" --> "") is output. (Output process as a single cell of the CSV format) |
$csv.values(String…) -- Takes multiple strings as arguments (variable-length arguments) and outputs the strings into a single line with the CSV format; the output format of a single cell is same as the value(String) function described previously. | |
$csv.values(Collection<String>) -- Takes an array and outputs the array into a single line with the CSV format; the output format of a single cell is the same as the value(String) function described previously. |