Import data

Command group Flag affected Reversible Execute on client Platform(s)
Importing and Exporting YES NO NO All

Syntax

Import data list-or-row-name

Description

This command reads the next data item into the specified list or row variable. You use the Import data command to import data from a file or port. Once you select an import file or port, and issue a Prepare for import command, Import data adds the data to the specified list or row variable.

If a record is successfully read from the file or port, Omnis sets the flag. An error occurs if the import file or port is closed or if the specified list or row variable does not exist. The flag is set after reading a record successfully.

After the import is complete, you should follow Import data with an End import and the appropriate Close import file or Close port.

There is a one-to-one mapping between the columns or fields in the import file and the columns in the list or row variable. Therefore, if there are fewer columns or fields in the import file than in the list or row, the excess import columns or fields are ignored. Likewise, if there are more columns in the list or row than in the import file, the excess columns are left blank.

The ‘LFonlyLineTermination’ item in the ‘default’ section of config.json allows you to control how carriage returns and line feeds are handled when importing data from a file. If true, when Omnis imports a tab- or comma-separated file and the file has no Carriage Return (CR) line separators, Omnis will then check for Line Feed (LF) line separators and use these to break record rows.

Example

# import from a csv file called myImport.txt in the root of your omnis tree
Calculate lImportPath as con(sys(115),'myImport.txt')
Set import file name {[lImportPath]}
Prepare for import from file {Delimited (commas)}
Import data lImportList
End import
Close import file