Importing Data from an XML File
You can import data directly from an XML file, specifying a specific data sheet.
You can either import XML files in two different ways:
By dragging and dropping the XML source file directly onto the stage.
By using the Import from Xml File task. The advantage of using the task is that you can configure the import options and decide whether you want to specify a single or multiple XML files:
Single XML file: only one file is imported, specifying the datasheet from which information will be taken.
Multiple XML files: in this case the files are concatenated to form a single table. Consequently, all files imported together must have the same structure.
Wildcards can be used in a filename/file list. For example, entering C:\Software*.csv during a file import, will result in the bulk import all the files in the Software folder, whose extension is .csv. Wildcards can be used in file names, but not in folder names, or in file extensions. Remember that only wildcard (*) can be used in the file path, and any consequent asterisks will be considered an effective part of the path, and not a wildcard. If the file extension is not actually specified when using a wildcard, files with extensions appropriate to the task in use will be searched for. For example, the extensions .xlsx, .xlsm for Import from Excel File, and .csv, .txt, .tab, etc. for Import from Text File.
Prerequisites
You must have created a process in Rulex.
If multiple files are imported, they must all have the same structure.
Additional tabs
The following additional tabs are provided:
Documentation tab where you can document your task,
Parametric options tab where you can configure process variables instead of fixed values. Parametric equivalents are expressed in italics in this page (PO).
Procedure
Drag and drop the Import from Xml File task onto the central stage.
Double click the task.
If you want to import data via a remote connection, such as HTTP API, SharePoint site or FTP, select the corresponding source from the Source file URI (uri) drop-down list and configure the connection in the Remote Connections tab.
To import a single file:
Click Select file to browse to the XML file you want to import and click Open, or manually enter the name of the file in the corresponding edit box (filename): the Table preview pane displays the data that will be imported into Rulex, and is dynamically updated each time you change any of the available options.
Configure the options as explained in the Parsing and Import options below.
To import multiple files:
Click on the Advanced tab and configure the options as explained in the Multiple file options below.
Save and compute the task.
Parsing options: | ||
Parameter Name | PO | Description |
---|---|---|
Number separators | decsep, thousep | Select the symbols used to mark decimals (decsep) and thousands (thousep) in numbers. |
Missing string | missingstr | Specify a character (or string of characters), which can be used to indicate missing values. |
Key for types | typestr | Enter the name of the attribute that defines the data type of the columns in the XML file. |
Import options: | ||
Remove empty rows | delemptyrows | If selected, empty rows are automatically deleted. |
Remove empty columns | delemptycols | If selected, empty columns are automatically deleted. |
Strip spaces | stripspaces | If selected, all spaces are removed from strings. For example, the string ” age ” is then imported as “age”. |
Compress white spaces | onlyonespace | Select this option to remove extra consecutive spaces from within strings. For example the string "university program" would be imported as "university program". |
Add an attribute containing filename | addfilename | If required you can add an extra column to the dataset with the name of the file. |
Use old computation data if source file is not available | useolddata | If selected, data from the previous computations will be used if the source table is not available. |
Continue the execution if the file is missing | continue | If selected, computation of the task continues, even if the selected source files are not available. |
Turn off smart type recognition | nosmarttype | If selected, the the data types of attributes is not automatically recognized, leaving the generic nominal type. This option is useful when manual identification is preferable, for example when there is the risk of a code being misinterpreted as a date. |
Add group columns | addgroups | If selected, a column is added containing additional information on the group tags belong to within the dataset (for example, 1,1,1,2,2,3,3 if there are 3 possible groups). |
Remove the most external tag when importing dataset | removetag | If selected, the most external tag is removed when importing the dataset. |
Wait until the target file is present | checkfile, sleeptime | If selected, Rulex polls the target file with the frequency specified (sleeptime) until it is available. |
Number of records to preview | nrecords | Specify how many records the table preview will display. |
Multiple file options: | ||
Concatenation type | cattype | Select the required concatenation type, which may be:
|
Match columns by | byname | Select whether you want to match columns by:
|