Skip to main content
Version: 4.48.0

File Reader

The File Reader component reads text-based files (such as .csv-files) and it's able to parse them. In order to access the local filesystem, the XILL4_WORKDIRS environment variable must be set to the path of the directory to be accessed.

Configuration

Path

Path to the file, can be a variable.

Example 1: ../test.csv

Example 2: %filePath%

Encoding One of the following encodings can be chosen:

  • UTF-8
  • ASCII

Parsing

Parse CSV

Parses CSV, separating using the delimiter.

Delimiter
The symbol that will separate columns.

Example:

With delimiter semicolon

Input row: first,name;last name 
Output: ['first,name', 'last name']

Text qualifier
The character to use to quote fields that contain a delimiter.

Example:

Input row: "first,name",last name 
Output: ['first,name', 'last name']

Treat first row as a header Transforms the rows in objects where the keys are the headers (first row)

Example:

{
"first name":"Jason",
"last name":"Dick",
}

Parse XML

Parses XML. The following configuration can be applied to the parser. By default, attributes and comments are not parsed.

Allow Boolean Attributes
Allows attributes without value. By default boolean attributes are ignored. When set to true:

<hello checked>
world
</hello>

will be parsed to:

{
hello: {
"@_checked": true,
"#text": "world"
}
}

Always Create Text Node
Force rendering a tag with text-node. Otherwise, it creates a property with the tag name and assign the value directly.
Example:

<hello>
world
</hello>

With alwaysCreateTextNode set to false:

{
hello: "world"
}

With alwaysCreateTextNode set to true:

{
hello: {
"#text": "world"
}
}

Parse Comments
Comments are parsed with prop name @_comments.
Example:

<hello>
<!--world-->
</hello>

Will parse to:

{
hello: {
"@_comments": "world"
}
}

Ignore Attributes
Attributes are ignored by the parser. By default set to true. This also means that any configuration regarding attributes will not apply.

Parse Attribute Value
Force parsing the attribute value. This is relevant when attribute values have another type than string.
Example:

<hello attr="true">
world
</hello>

With parseAttributeValue to false:

{
hello: {
"@_attr": "true"
}
}

With parseAttributeValue to true:

{
hello: {
"@_attr": true
}
}

Parse Tag Value
Force parsing the tag value. Same logic applies as with parseAttributeValue.

Preserve Order
Used to keep the order of tags in the result object.

Remove NS Prefix
Remove namespace string from tag and attribute names.
Example:

<ns:hello ns:attr="true">
world
</ns:hello>

Will parse to:

{
"hello": {
"@_attr": "true"
}
}

Unpaired Tags
Unpaired Tags are the tags which don't have matching closing tag. Eg <br> in HTML. You can parse unpaired tags by setting the unpaired tags separated by a comma (,).
Example:

<hello>
world
<br>
</hello>

With unpairedTags set to br will parse to:

{
hello: {
"#text": "world",
unpaired: ""
}
}

Parse JSON

Parses the file as a JSON and outputs an object

Inputs

Input

Takes any input as a trigger. If the input is an object with the path key, this value will replace the path in the configuration.

Example:


{
"path" : "C:\\Migration Data\\new.csv"
}

Outputs

Output

When not parsing:

The input data and the contents of the file

Example:

{
value:{
path: "C:\\Migration Data\\new.csv",
},
result: "name,street,city\rPeter,221B Baker Street,London\rBob,First Avenue,New York"
}

When parsing, depending on the settings:

Example without first row as headers:

{
"result" : "name, street, city"
},
{
"result" : "Peter, 221B Baker Street, London"
},
{
"result" : "Bob, First Avenue, New York"
}

Example with first row as headers:

{
"result" : {
"name":"Peter",
"street":"221B Baker Street",
"city":"London"
}
},
{
"result" : {
"name":"Bob",
"street":"First Avenue",
"city":"New York"
}
},