4.2.18 File export plug-in
Function
This plug-in outputs the specified value into a desired format.
This plug-in uses Apache Velocity Engine to format the specified value.
Cautionary notes
-
If execution of a task is stopped during plug-in execution, the status of the task becomes Failed or Completed when the processing of the file export plug-in has finished. The status of steps and tasks after plug-in execution has finished depends on the return code of the step and the condition for executing subsequent steps. You can set Subsequent-step Execution Condition in the Create Step dialog box or the Edit Step dialog box.
-
When you forcibly terminate a task while the plug-in is running, the processing being executed is immediately forcibly terminated and the task enters Failed status. A return code of 80 appears for the step in the Flow area of the Tasks window. The return code output to the task log depends on the timing in which the task was forcibly terminated.
Version
01.00.00
Tag
File Operations
Return codes
Return code |
Description |
---|---|
0 |
Ended normally. |
1 |
The specified output destination file path is too long. |
2 |
Code written in VTL (Velocity Template Language) has syntax errors. |
3 |
An internal error occurred. |
4 |
An internal error occurred. |
5 |
An error occurred while data was being written to the output file. |
63 |
An internal error occurred. |
80 |
Task execution has stopped. |
Property list
The following table describes the properties.
Property key |
Property name |
Description |
Default value |
I/O type |
Required |
---|---|---|---|---|---|
content |
Content To Export |
Specify the character string to be formatted and output to a file. |
-- |
Input |
R |
fileName# |
Output File Name |
Specify the output file name. |
-- |
Input |
R |
directoryPath# |
Output Directory Path |
Specify the absolute path or relative path of the folder in which the output file is to be stored. If this property is not specified, the following folder is used. If a relative path is specified, the folder specified for this property is used as the base folder.
|
-- |
Input |
O |
template |
Template For The Output |
Specify the output format of the specified value. Note that you must specify the output format with VTL. If this property is not specified, the input value is output as is. |
-- |
Input |
O |
charset |
Character Set |
Specify the character encoding of the output file. You can specify one of the following encodings. The specified value is not case sensitive.
|
-- |
Input |
O |
exportFilePath |
Output File Path |
The full path of the output file is output to this property. |
-- |
Output |
O |
Message |
Message |
An error message occurring during execution of the plug-in is output to this property. |
-- |
Output |
O |
- #
-
-
The total length of the values specified for the fileName and directoryPath properties must not exceed 256 characters. If the total length exceeds 256 characters, an error occurs.
-
If there is already a file that has the specified name, the file is overwritten.
-
If there is already a file that has the specified name, an error occurs. In this case, a return code of 5 is returned.
-
Reserved variables that can be specified for the template property
When specifying the template property, follow VTL. The file export plug-in provides the reserved variables that can be used for specification of that property.
-
$root
If the character string specified for the content property is JSON-formatted, the character string is output as a JSON-decoded object. If the character string specified for the content property is not JSON-formatted, the character string is output as an ordinary character string.
-
$csv.value(String)
If you specify a single character string as an argument, the resulting value is output in the format that is equivalent to one field of the CSV format. For example, if the specified character string includes a character that must be escaped in the CSV format, the character string is enclosed in double quotation marks ("). Double quotation marks (") included in the specified character string are escaped.
-
$csv.values(String...)
If you specify multiple character strings as arguments, the resulting value is output in the format that is equivalent to one line of the CSV format.
-
$csv.values(Collection<String>)
If you specify a string array as an argument, the resulting value is output in the format that is equivalent to one line of the CSV format.
Examples of specifying the content and template properties
-
If a character string that is not JSON-formatted is specified for the content property and the template property is omitted
Value of content
Value of template
Data to be output
Hello!
Not specified
Hello!
-
If a character string that is JSON-formatted is specified for the content property and the template property is omitted
Value of content
Value of template
Data to be output
{ "task": "Daily batch", "result": "success" }
Not specified
{ "task": "Daily batch", "result": "success" }
-
If a character string that is not JSON-formatted is specified for the content property and the $root reserved variable is specified for the template property
Value of content
Value of template
Data to be output
success
The result is $root!
The result is success!
-
If a JSON format (object) is specified for the content property and the $root reserved variable is specified for the template property
Value of content
Value of template
Data to be output
{ "task": "Daily batch", "result": "success" }
The result of $root["task"] was $root["result"]!
The result of Daily batch was success!
-
If a JSON format (array) is specified for the content property and the $root reserved variable is specified for the template property
Value of content
Value of template
Data to be output
[ "success", "fail", "success" ]
The results are #foreach ($result in $root) $result #end
The results are success fail success
-
If a JSON format is specified for the content property and the $csv.values(String...) reserved variable is specified for the template property
Value of content
Value of template
Data to be output
[ { "task": "Daily batch", "result": "success" }, { "task": "Weekly batch", "result": "fail" } ]
$csv.values("task", "result") #foreach($row in $root) $csv.values($row["task"], $row["result"]) #end
task,result Daily batch,success Weekly batch,fail
-
If a JSON format is specified for the content property and the $csv.values(Collection<String>) reserved variable is specified for the template property
Value of content
Value of template
Data to be output
[ ["task", "result"], ["Daily batch", "success"], ["Weekly batch", "fail"] ]
#foreach($row in $root) $csv.values($row) #end
task,result Daily batch,success Weekly batch,fail
-
If the content property contains double quotation marks (") and commas (,), which must be escaped in the CSV format, and the $csv.values(Collection<String>) reserved variable is specified for the template property
Value of content
Value of template
Data to be output
[ "normal", "\"quoted\"", "Hello, World", "double \" quote" ]
$csv.values($root)
normal,"""quoted""", "Hello, World","double "" quote"
-
If the content property contains line breaks, which must be escaped in the CSV format, and the $csv.values(Collection<String>) reserved variable is specified for the template property
Value of content
Value of template
Data to be output
line1 line2 line3
$csv.value($root)
"line1 line2 line3"