Spectre Flow Output Code Blocks
Spectre Flow output code blocks export a data flow to a specified file type.
The cBase Output code block writes data to a cBase. For information about the corresponding Spectre Flow Editor object, see Spectre Flow cBase Output Object. The cBase Output code block has the following structure:
cbase-output "<name>" {
source "<source>"
file "<file>"
}
cBase Output Tags
Specifies the name of the output cBase file.
The Flow Output code block allows a Spectre Flow script to be used as a data source for another process, such as another Spectre Flow script or a DivePort portlet. When a Spectre Flow Output code block exists, all other outputs are ignored. Only one Flow Output code block may be used in a Spectre Flow script. For information about the corresponding Spectre Flow Editor object, see Spectre Flow Flow Output Object. The Flow Output code block has the following structure:
flow-output "<name>" {
source "<source>"
}
The JSON Output code block writes data to a .json (JavaScript Object Notation) file. The output file format is an array of objects, with each object containing one row of data.
Given a table as follows:
| Customer ID | Customer Name | Customer Address |
|---|---|---|
| 1 | John Doe | 123 Main St |
| 2 | Jane Doe | 456 River St |
| 3 | Bob Bobson | 10 Downing St |
| 4 | Jill Jackson | 1600 Pennsylvania Ave |
The JSON output is:
[
{
"Customer ID": 1,
"Customer Name": "John Doe",
"Customer Address": "123 Main St"
},
{
"Customer ID": 2,
"Customer Name": "Jane Doe",
"Customer Address": "456 River St"
},
{
"Customer ID": 3,
"Customer Name": "Bob Bobson",
"Customer Address": "10 Downing St"
},
{
"Customer ID": 4,
"Customer Name": "Jill Jackson",
"Customer Address": "1600 Pennsylvania Ave"
}
]
The JSON Output code block has the following structure:
json-output "<name>" {
source "<source>"
file "<file>"
}
JSON Output Tags
Specifies the name of the output .json file.
If present, and a file with the same name and file path as the file tag exists, then the existing file is only overwritten if there is a difference between the existing file and the output file. Optional.
The Text Output code block writes data to a text file. For information about the corresponding Spectre Flow Editor object, see Spectre Flow Text Output Object. The Text Output code block has the following structure:
text-output "<name>" {
source "<source>"
file "<file>"
encoding "<encoding>"
append
no-headers
delimiter "<tab|comma|other-delimiter>"
only-if-different
split-file {
filename-column "<column>"
filename-prefix "<prefix>"
filename-suffix "<suffix>"
}
}
Text Output Tags
Specifies the name of the output text file.
Specifies the encoding of the output file. Default value is utf8. Optional.
If present, the output is appended to the file. By default, headers are still included unless the no-headers tag is present.
If present, the header line is omitted in the output. Optional.
Specifies the delimiter character. Use either a single character literal or, if the delimiter is a tab or comma, by name as either tab or comma. The default value is tab. Optional.
If present, and a file with the same name and file path as the file tag exists, then the existing file is only overwritten if there is a difference between the existing file and the output file. Optional.
If present, string values containing quotation marks are not output with additional quotation marks. For example, a row value of John "Jim" Doe is given wrapping quotes when no-quotes is not present, and the output is "John ""Jim"" Doe". With no-quotes present, the output is John "Jim" Doe.
If present, all column formatting from previous code blocks is retained and used when the data is output. If not present, default formatting applies. For example, a date with a custom format such as "MM-YYYY" is only output with that formatting when this tag is present. Otherwise, the date is formatted as YYYY/MM/DD (the default format).
If present, the output data is split into a set of files determined by the contents of the data. For example, splitting a file based on a dimension called YesNo containing either "Yes" or "No" values, splits into two text files: Yes.txt and No.txt. The values in any other columns are output as well as part of the split files. Has the following sub-tags:
-
filename-column—Sets the column to perform the split on. Every unique value in this column is turned into an output file.
-
filename-prefix—Sets the prefix for the split file name. This prefix can include a file path if you want the file to output to a specific folder.
-
filename-suffix—Sets the suffix of the split file name. This suffix can include a file type. For example, .txt. If you do not provide a file type in the suffix field, a file type will not be given to the output split file.