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

  1. Enter the delimiter that separates values in the file.

    • comma (,)
    • semicolon (;)
    • A blank space
    • bar (|) 
  2. Check the radio button to indicate if headers are present. 

  3. If headers are present, check the radio button if the headers should be:

    • Upper case
    • Lower case
    • Original 
  4. Select the character set for the CSV 

  5. 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:ss

    • Convert to String - All fields are set to the String data type.

  6. 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.

Strings, dates, and numeric data types that are parsed with no value in the field are given a null value.

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.

  1. 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: { ... }
     }
    }
  2. 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"}
  3. 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.

  4. 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.