[attr := ] OUTPUT(recordset, [ format ] ,file , CSV[ (csvoptions) ] [, CLUSTER( target )] [,ENCRYPT(key) ] [,COMPRESSED]
[, OVERWRITE ][, UPDATE] [, EXPIRE( [ days ] ) ] )
CLUSTER | Optional. Specifies writing the file to the specified list of target clusters. If omitted, the file is written to the cluster on which the workunit executes. The number of physical file parts written to disk is always determined by the number of nodes in the cluster on which the workunit executes, regardless of the number of nodes on the target cluster(s). |
target | A comma-delimited list of string constants containing the names of the clusters to write the file to. The names must be listed as they appear on the ECL Watch Activity page or returned by the Std.System.Thorlib.Group() function, optionally with square brackets containing a comma-delimited list of node-numbers (1-based) and/or ranges (specified with a dash, as in n-m) to indicate the specific set of nodes to write to. |
ENCRYPT | Optional. Specifies writing the file to disk using both 256-bit AES encryption and LZW compression. |
key | A string constant containing the encryption key to use to encrypt the data. |
COMPRESSED | Optional. Specifies writing the file using LZW compression. |
OVERWRITE | Optional. Specifies overwriting the file if it already exists. |
UPDATE | Specifies that the file should be rewritten only if the code or input data has changed. |
EXPIRE | Optional. Specifies the file is a temporary file that may be automatically deleted after the specified number of days. |
days | Optional. The number of days after which the file may be automatically deleted. If omitted, the default is seven (7). |
This form writes the recordset to the specified file in the specified format as a comma separated values ASCII file. The valid set of csvoptions are:
HEADING( [ headertext [ , footertext ] ] [, SINGLE ][, FORMAT(stringfunction) ] )
HEADING | Specifies file headers and footers. |
headertext | Optional. The text of the header record to place in the file. If omitted, the field names are used. |
footertext | Optional. The text of the footer record to place in the file. If omitted, no footertext is output. |
SINGLE | Optional. Specifies the headertext is written only to the beginning of part 1 and the footertext is written only at the end of part n (producing a "standard" CSV file). If omitted, the headertext and footertext are placed at the beginning and end of each file part (useful for producing complex XML output). |
FORMAT | Optional. Specifies the headertext should be formatted using the stringfunction. |
stringfunction | Optional. The function to use to format the column headers. This can be any function that takes a single string parameter and returns a string result |
SEPARATOR | Specifies the field delimiters. |
delimiters | A single string constant (or comma-delimited list of string constants) that define the character(s) used to delimit the data in the CSV file. |
TERMINATOR | Specifies the record delimiters. |
QUOTE | Specifies the quotation delimiters for string values that may contain SEPARATOR or TERMINATOR delimiters as part of their data. |
ASCII | Specifies all output is in ASCII format, including any EBCDIC or UNICODE fields. |
EBCDIC | Specifies all output is in EBCDIC format except the SEPARATOR and TERMINATOR (which are expressed as ASCII values). |
UNICODE | Specifies all output is in Unicode UTF8 format |
If none of the ASCII, EBCDIC, or UNICODE options are specified, the default output is in ASCII format with any UNICODE fields in UTF8 format. The other default csvoptions are:
CSV(HEADING('',''), SEPARATOR(','), TERMINATOR('\n'), QUOTE())
Example:
//SINGLE option writes the header only to the first file part:
OUTPUT(ds,,'~thor::outdata.csv',CSV(HEADING(SINGLE)));
//This example writes the header and footer to every file part:
OUTPUT(XMLds,,'~thor::outdata.xml',CSV(HEADING('<XML>','</XML>')));
//FORMAT option writes the header using the specified formatting function:
IMPORT STD;
OUTPUT(ds,,'~thor::outdata.csv',CSV(HEADING(FORMAT(STD.Str.ToUpperCase))));