Library Elements Data_import and Data_import_Excel

This article familiarizes the user with the library elements “Data_import” and “Data_Excel_import” which are different procedures to run Import Steps (defined in the Data Center) in the coding environment. Both library elements can be found in the Libraries pad of Soley Studio in the category Data .

Data_import

When to use

If you want to run an Import Step that you have created in the Data Center in the coding environment, e.g. as part of a sequence, you must use the library element Data_import. The Import Step defines both the data source, i.e. the file or database that is imported, and the mapping of the data to a node class and its attributes.

Syntax

Data_import(IMPORTSTEP_FILEPATH)

It is a procedure and needs to be called accordingly, as shown in the example below.

Input Parameters

IMPORTSTEP_FILEPATH:string – a string value describing the path to an Import Step file, i.e. an *.slis file. The path needs to be given relative to the project path (see example below).

Returns

There are no return values. The library element will run the Import Step. See the Output pad for details on the import.

Example


sequence Data_import_trial{
{Data_import("Data Center\\Data Sources\\MyImportStep1.slis")}
}

You may copy this example, change the name of the import step to yours and run the sequence to import your data into the memory. Pay attention to

  • the curly brackets used to call the procedure in the sequence context
  • the exclamation marks denoting the string input parameter
  • the file path relative to the project path “Data Center\\Data Sources\\…”
  • the fact that filetype of the import step must be *.slis

Data_Excel_import

When to use

If you want to run an Import Step that you have created in the Data Center in the coding environment, e.g. as part of a sequence, AND you want to specify an Excel file as Data source, you must use the library element Data_Excel_import. In this case the Import Step defines only the mapping of the data to a node class and its attributes. The Excel data source can be defined as a parameter. This is especially handy if you have a high number of Excel files of the same structure that you want to import meaning that the mapping always stays the same bit the filename changes. Imagine you have 100 Excel files of the same structure that you want to import. Instead of creating 100 Import Steps using the Data Center you only have to create one and reuse it for all files.

Syntax

Data_Excel_import(IMPORTSTEP_FILEPATH, DATA_FILEPATH)

It is a procedure and needs to be called accordingly, as shown in the example below.

Input Parameters

IMPORTSTEP_FILEPATH:string – a string value describing the path to an Import Step file, i.e. an *.slis file. The path needs to be given relative to the project path (see example below).

DATA_FILEPATH:string – a string value describing the path to an Excel file, i.e. an *.xlsx or *.xls file. The path needs to be given relative to the project path (see example below).

Returns

There are no return values. The library element will run the Import Step on the specified Excel file. See the Output pad for details on the import.

Example


sequence Data_Excel_import_trial{
{Data_Excel_import("Data Center\\Data Sources\\MyImportStep1.slis","Data\\Product1_Data.xlsx")}
& {Data_Excel_import("Data Center\\Data Sources\\MyImportStep1.slis","Data\\Product2_Data.xlsx")}
}

You may copy this example, change the name of the import step to yours and run the sequence to import your data into the memory. Pay attention to

  • the curly brackets used to call the procedure in the sequence context
  • the exclamation marks denoting the string input parameters
  • the file paths relative to the project path
  • the fact that filetype of the import step must be *.slis

Using the library element Data_Excel_import works great if you loop through an array of file paths. We will soon release another library element that allows you to build such an array for all files in a folder. Stay tuned!

Where to find the library elements

Both library elements are part of the Foundations/Data library that comes with Soley Studio. Go to the Libraries tool and select the category Data –> Data_import or Data_Excel_import.

Was this article helpful?

Related Articles