File Reader
The File Reader component reads text-based files (such as .csv
-files) and it's able to parse them. The local file system or a cloud storage can be used. 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 to the file, can be a variable.
Example 1: ../test.csv
Example 2: %filePath%
Example 3: C:/testFolder
The component also supports reading out files from a cloud storage.
Example 4: <cloud-storage>://testFolder/test.csv
One of the following encodings can be chosen:
- UTF-8
- ASCII
Parsing
Parse CSV
Parses CSV, separating using the delimiter
.
The symbol that will separate columns.
Example:
With delimiter semicolon
Input row: first,name;last name
Output: ['first,name', 'last name']
The character to use to quote fields that contain a delimiter.
Input row: "first,name",last name
Output: ["first,name", "last name"]
Transforms the rows into 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 AttributesAllows 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"
}
}
Force rendering a tag with a text node. Otherwise, it creates a property with the tag name and assigns the value directly.
Example:
<hello>
world
</hello>
With alwaysCreateTextNode
set to false
:
{
hello: "world"
}
With alwaysCreateTextNode
set to true
:
{
hello: {
"#text": "world"
}
}
Comments are parsed with prop name @_comments
.
Example:
<hello>
<!--world-->
</hello>
Will parse to:
{
hello: {
"@_comments": "world"
}
}
Attributes are ignored by the parser. By default set to true. This also means that any configuration regarding attributes will not apply.
Parse Attribute ValueForce parsing the attribute value. This is relevant when attribute values have another type than string.
Example:
<hello attr="true">
world
</hello>
With parseAttributeValue
set to false
:
{
hello: {
"@_attr": "true"
}
}
With parseAttributeValue
set to true
:
{
hello: {
"@_attr": true
}
}
Force parsing the tag value. Same logic applies as with parseAttributeValue
.
Used to keep the order of tags in the result object.
Remove NS PrefixRemove namespace string from tag and attribute names.
Example:
<ns:hello ns:attr="true">
world
</ns:hello>
Will parse to:
{
"hello": {
"@_attr": "true"
}
}
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 | Outputs
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"
}