exportCsv
|
The exportCsv function with its Lambda argument provides powerful programmable export functionality. The
Lambda performs any necessary editing, and may be programmed to generate any header or trailer records that may be
necessary. The exportCsv function natively generates text records to a specified file. Each record is
separated by a line terminator eol (end-of line) character that applicable to the operating system. By specifying the recordsOnly: argument, the Lambda of exportCsv function supplies the data to
be exported as a single record. By specifying the recordVectors: option, the Lambda will pass data to the
exportCsv function as a collection of records saved in an aggregate container such as a Vector, Structure
or Dictionary. Usage The exportCsv function is typically used to export or convert data into formats for non-Analytic Information
Server applications. The native exportCsv makes no assumptions of the format of the foreign data (it may
have header records or not, it may have trailer records or not, the output fields may be comma-delimited, or comma-delimited,
or have no fields at all). The Lambda specified as the anLambda argument is the Lambda handles the formatting and
editing details and passes the record to exportCsv. The exportCsv function receives the pre-formatted
text record and simply writes it out to a file. In order for the exportCsv function to work properly, the
anLambda argument is required to have a child Lambda named refExport(row):.
The result file from the exportCsv function is a text file. The optional argument, recordVectors:,
is useful when the desired result file consists of records consisting of comma-delimited fields. When recordVectors:
is specified, the Lambda will pass an aggregate data container such as a Vector, Structure, or Dictionary to the
exportCsv function. The exportCsv function will extract each item from the Vector, Structure, or
Dictionary and convert each item into text and enter it in a record, separating each data item with a #\,
character. The second optional argument, recordsOnly, requires that the Lambda perform the formatting and text
conversion. If recordsOnly is specified, the exportCsv function will call the Lambda's refExport and will
expect a single text record and will simply write out the record. refExport ChildLambda
refExport(row)
Called by exportCsv function to request a record or vector from an Lambda. The refExport method receives a
row argument and must return one of the following containers, String, Vector, Structure or Dictionary. If the
container is a Vector, Structure or Dictionary, exportCsv will format each item as comma-delimited text fields
in a record and then write out the record to the file. The refExport method is required to return a Boolean
value of false to indicate that no more records are to be exported.
(exportCsv fileid anLambda) (exportCsv fileid anLambda recordsOnly:) (exportCsv fileid anLambda recordVectors:) The number of rows exported.
Expression:
Arguments
Name
Type
Description Argument: fileid Text
A file identifier previously obtained from a call to fileopen for an Lambda comma delimited file. Argument: anLambda Lambda
Mandatory Lambda. The anLambda Lambda is called by the exportCsv function to request a record or vector from
an Lambda. The anLambda Lambda must have a child Lambda named refExport. The refExport method receives a row
argument and must return one of the following containers, String, Vector, Structure or Dictionary. If the
container is a Vector, Structure or Dictionary, exportCsv will format each item as comma-delimited text fields
in a record and then write out the record to the file. The refExport method is required to return a Boolean
value of false to indicate that no more records are to be exported. Argument: recordsOnly: Symbol
Optional argument.. If present, the exportCsv function sends the Lambda a record that is delimited by the
system end-of-line (eol) character. Note: In the Intel-base platforms, the standard record terminator is
carriage-return, line-feed (CR)(LF). 68000-based platforms (such as the Mac OS) use a single eol character:
(CR). Argument: recordVectors: Symbol
Optional argument. If present, the exportCsv function sends the Lambda a Vector or other aggregate container.
The individual elements of the vector are converted to text and each text fields is separated by the #\, (comma)
character.
Returns:
Here are a number of links to Lambda coding examples which contain this instruction in various use cases.
Here are the links to the data types of the function arguments.
ObjectRepository | Text | Lambda | String |
Vector | Structure | Dictionary | Boolean |
Integer |
Here are also a number of links to functions having arguments with any of these data types.
Analytic Information Server (AIS)AIS Component Systems
|