OUTPUT CSV Files

[attr := ] OUTPUT(recordset, [ format ] ,file , CSV[ (csvoptions) ] [, CLUSTER( target )] [,ENCRYPT(key) ] [,COMPRESSED]

[, OVERWRITE ][, UPDATE] [, EXPIRE( [ days ] ) ] )

CLUSTEROptional. 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).
targetA 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.
ENCRYPTOptional. Specifies writing the file to disk using both 256-bit AES encryption and LZW compression.
keyA string constant containing the encryption key to use to encrypt the data.
COMPRESSEDOptional. Specifies writing the file using LZW compression.
OVERWRITEOptional. Specifies overwriting the file if it already exists.
UPDATESpecifies that the file should be rewritten only if the code or input data has changed.
EXPIREOptional. Specifies the file is a temporary file that may be automatically deleted after the specified number of days.
daysOptional. 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) ] )

SEPARATOR( delimiters )

TERMINATOR( delimiters )

QUOTE( [ delimiters ] )

ASCII | EBCDIC | UNICODE

HEADINGSpecifies file headers and footers.
headertextOptional. The text of the header record to place in the file. If omitted, the field names are used.
footertextOptional. The text of the footer record to place in the file. If omitted, no footertext is output.
SINGLEOptional. 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).
FORMATOptional. Specifies the headertext should be formatted using the stringfunction.
stringfunctionOptional. 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
SEPARATORSpecifies the field delimiters.
delimitersA single string constant (or comma-delimited list of string constants) that define the character(s) used to delimit the data in the CSV file.
TERMINATORSpecifies the record delimiters.
QUOTESpecifies the quotation delimiters for string values that may contain SEPARATOR or TERMINATOR delimiters as part of their data.
ASCIISpecifies all output is in ASCII format, including any EBCDIC or UNICODE fields.
EBCDICSpecifies all output is in EBCDIC format except the SEPARATOR and TERMINATOR (which are expressed as ASCII values).
UNICODESpecifies 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))));