importSbf
|
The importSbf function with its Lambda argument provides powerful programmable export functionality. The Lambda performs any necessary editing of the imported records, and may be programmed to process any header or trailer records that an incoming file may have. The importSbf function natively parses comma-delimited fields, but again, can be programmed to parse any record with no fields or any record with fields that are delimited by any character. The only assumption made by the importSbf function, is that the file is a text file and that each record is separated by a line terminator eol (end-of line) character that applicable to the operating system.
The Lambda is responsible for supplying a container to accept the imported fields. The container must be appropriate to handle the type of data it is to receive. By specifying the {recordsOnly:} argument, the Lambda of importSbf function makes the assumption the data to be imported as a single record that is terminated by the eol character. By specifying the {recordVectors:} option, the Lambda will make the assumption that the data it is receiving from the importSbf function is a collection of fields, therefore the container must be an aggregate container such as a Vector, Structure or Dictionary to accept multiple fields.
Usage
The importSbf function is typically used to import or convert data from non-Analytic Information Server applications. The native importSbf 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)where the data should go nor does it have any built-in editing algorithms for the imported data. The Lambda handles the container and editing issues. In order for the importSbf function to work properly, the Lambda argument must be supplied and must have the refImport(row) and the setImport(row) child Lambdas.
refExport(row) | Called by importSbf function to receive an empty container from the Lambda. The refImport method receives a row argument and must return an empty container. The empty container will be used to store the next imported record. |
setImport(row container) | Called when importSbf is finished filling the record with data. The setImport function receives a row index argument and a record argument. The record argument is the filled container record. The Lambda may process the filled container in any manner. |
The only requirement of the importSbf function is that the imported file must be text. The optional argument, recordVectors:, is useful when it is known by the Lambda that the records consists of EOF-delimited fields. When recordVectors: is specified, the record is automatically parsed and the individual fields are stored as items in an aggregate container, such as a Vector, Structure, or Dictionary. The Lambda establishes the container type and it is passed from the Lambda to the importSbf function via the refImport method. When the importSbf function is finished filling the container it passes the filled-in container to the Lambda, setImport method then receives the container and performs the desired formatting or editing.
Expression: | (importSbf fileid anLambda) (importSbf fileid anLambda recordsOnly:) (importSbf fileid anLambda recordVectors:) |
---|
Arguments | Name | Type | Description |
Argument: | fileid | Text | A file identifier previously obtained from a call to fileopen for an Lambda EOF delimited file. |
---|---|---|---|
Argument: | anLambda | Lambda | Mandatory Lambda. An Lambda which is to be imported in EOF delimited format. If an object Repository may be passed, the Object repository's Librarian will be used as the import Lambda. |
Argument: | recordsOnly: | Symbol | Optional argument.. If present, the importSbf 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 importSbf 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 EOF = (char 1) character. |
Returns: | The number of rows imported. |
---|
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
|