Work with Parsers
Introduction
Parsers are an important part of Hero Platform_. They do not have a dedicated location in the UI and found within Inputs, Lookups and functions.
Example (CSV parser within a File System Input):
The above image is a File System Input form and the yellow box shows the CSV parser section. After selecting the input format (CSV in this example), there are fields for configuring the parser. Different parsers have different configuration fields.
How Parsers are Used in Hero Platform_
Parsers are used for filling the field mapping table with detected data or from a predefined list. With their configuration and the field mappings they generate tuples or tuple field values from input bytes.
Available Parsers
CSV
Enter the delimiter that separates values in the file.
- comma (,)
- semicolon (;)
- A blank space
- bar (|)
Check the radio button to indicate if headers are present.
- If the radio button for "Yes" is selected:
- Hero Platform_ assumes empty values for ensuing rows which have less values than the header row.
- If the radio button for "No" is selected:
- Hero Platform_ may fail to detect field types when the CSV file has ensuing rows which have less values than the first row.
- If the radio button for "Yes" is selected:
If headers are present, check the radio button if the headers should be:
- Upper case
- Lower case
- Original
Select the character set for the CSV
Select the field detection strategy:
Detect types - Hero Platform_ automatically detects the data types for each field.
Values of fields that have a Date_Time data type require the following format: yyyy-MM-dd HH:mm:ssConvert to String - All fields are set to the String data type.
- Enter example text for detecting. (Optional)
If this field is filled, its content is used for the field detection. If the example text for detecting box is left empty, the parser reads from the Input.
Binary
Consumes the whole Input (a file or HTTP response body) and converts it to a single binary field.
Text
Consumes the whole Input (a file or HTTP response body) and converts it to a single text field.
A good choice for working with text files or providing Input data for JavaScript functions.
EML
Parses email fields. The Input must be a in EML format.
A good choice for parsing saved emails.
JSON
Consumes the whole Input (a file or HTTP response body). The Input must be a valid JSON.
Root path (optional) is used to parse only the part of JSON specified by the path. Other parts outside of the path are ignored. For the sample JSON below, users, meta or meta.settings are the valid root paths. Or Root path can be left empty.
{ users: [ {...}, {...}, ], meta: { settings: { ... } } }
Date_Time format is used for detecting and parsing the Date_Time fields in the Input JSON. Learn more about Hero Platform_'s Date_Time formats.
Below is a sample JSON fitting Hero Platform_'s default Date_Time format: yyyy-MM-dd HH:mm:ss{"lastModification": "2019-12-02 15:32:21"}
Mark flatten top level array box when the top level element (the root path is respected) in the JSON is an array.
- If the JSON's top level element is in an array and the feature box is marked, Hero Platform_ detects multiple individual tuples.
If the JSON's top level element is in an array and the feature box is not marked, Hero Platform_ could produce a list field with tuples.
In the example below, if the flatten top level array feature is marked, two String fields will be detected (id, name) and three tuples will be parsed. The results will be three separate lines in the field mapping.[ { id: "id1", name: "name1" }, { id: "id2", name: "name2" }, { id: "id3", name: "name3" } ]
If the flatten top level array feature is unmarked, a single field will be detected (LIST<TUPLE>) and only that one tuple will be parsed and list with the three id-name pairs in it.- Example text for detecting (optional) allows for copying and pasting a sample JSON into the box for field detection. If this field is filled, its content is used for the field detection. If the detecting text box is left empty, the parser reads from the Input (I.e. opens the Input file or does an HTTP request.)
You can always parse JSON data with the TEXT parser. Parsing JSON with a TEXT parser can be useful to feed a JavaScript function with Input data.
Log
Suitable for converting application log lines to tuples.
Ignore File Contents
This parsing feature is only supported for File System Inputs.
The ignore file contents parser is used when only the file names or file paths are required.
Use this parser to so that automation creators in Flow Studio can have access to file names and file paths without having to download the file contents.
The fields mapping table is always empty as file opening and parsing are ignored.
This mode provides a massive performance improvement by not downloading the files.