Search

Home

Home

Bits-to-Text Conversion Editor – User format

Bits-to-Text Conversion Editor – User format

The bits conversion editor allows the data stream of the data bus to be converted into any text format defined by the user in the editor. It enables the creation of nested structures and formatting of data originating from the data bus.

The editor is available in the following operators in the GRAVITY system:

CONVERT BITS TO FORMATCONVERT BITS TO FORMAT

BASIC INFORMATION

The data format schema is created by the person configuring the operator by entering arbitrary text. Markers are inserted into the text, allowing data from the data bus to be inserted and groups (loops) to be created. The markers are interpreted by the operator during input data processing.

Two types of markers are distinguished:

  • group markers → allow groups to be defined in the generated data format:
    • #S-group_name# → group start marker, for example: #S-G1#
    • #E-group_name# → group end marker, for example: #E-G1#
    • icon
      A group can be understood as a block of text (together with bit markers) that is interpreted and replicated in the output text according to the following processing logic. During processing, the operator groups all data from the data bus by the bits used in the processed group, filtered by the values of parent groups. It then replaces the text between the group markers with the processed content as many times as there are records produced by the grouping. During each processing iteration, bit markers are replaced with their corresponding values from the current iteration.
      icon
      At least one group is required in the text.
  • bit markers → data bus bits used within a group, separated from the text by start and end delimiters. The default delimiters are { and }, but you can change them in the operator that invokes the editor (CONVERT BITS TO FORMATCONVERT BITS TO FORMAT). An example of a bit marker is {name}.
  • icon
    Each use of a data bus bit in the text must be placed within a group marker.

The result of processing input data is a set of records containing text generated according to the defined format. The number of text records depends on the number of records produced by grouping the data from the data bus by the bits used in the first group. This means that the number of input records may differ from the number of output records. Therefore, if you want to obtain only a single output record, the first group should not contain any bit markers, or it should contain a bit that has the same value for all input records.

EDITOR CONFIGURATION

The editor window is divided into two areas: Busbar and User format definition.

image

The Busbar area displays a list of bus bits provided to the operator that invokes the editor. You can drag and drop any bit into the User format definition area if you want to use it to build the format structure.

The User format definition area is the main workspace where you build the conversion to your custom format. This area contains buttons that assist with building the format:

  • Load file → loads a format definition from a file.
  • Create group → inserts a data group marker. If you select text in the editor, the group marker will wrap the entire selected text. At least one data group is required in the defined format.
  • Ungroup → removes the group marker from the selected text.
  • Insert empty token → inserts an empty bus bit marker.
  • Show specificators → displays basic bit formatting options. Bit formats can be dragged into the text editor area. A bit marker with the selected formatting will then be inserted. The bit name must be entered manually.
  • Insert ordinal number in group → inserts a marker that is replaced during processing with a sequential ordinal number LP within the group. For each nesting level, it indexes successive positions in the group starting from 1.
  • Save → saves the format schema to the component that invoked the editor.
  • Save to file → saves the format to a file.

EXAMPLE OF CREATING A CUSTOM FORMAT

Let’s assume you want to create a text file containing an order summary. You want the report to include information about the number of orders in individual years, as well as a list of all orders without a yearly breakdown. The data has already been retrieved and processed so that the data bus contains bits storing annual summaries and the list of orders.

Start by inserting a group marker using the Create group button.

image

If you want to use any bits in the first grouping, drag them into the editor area. A bit marker {bit_name} will be inserted. In this case, we will not use any bits because we want to generate only a single output record containing the report, and the data does not include a field with a value common to all records.

image
icon
The result of the operator’s processing will be as many records with generated text as are produced by grouping the data bus according to the bits used in the first grouping.

Now let’s create a group representing the annual summary. It will contain information about how many orders were placed and the total value of those orders in each year. To achieve this, we need to add a new group because we want the data to be processed in a loop. Next, we enter the descriptive text and drag data bus bits into the editor, thereby inserting the corresponding bit markers.

image
icon
When interpreting group G2, the operator will first filter the bus data based on the bit markers used in group G1 (which are not present in our project), and then group the data by the bits t_order_year, t_report_orders_count and t_report_total_in_year.
icon
You can format a bit’s value by adding : after its name followed by the desired format, for example {t_report_total_in_year:N2}. Learn more about data formatting.

To insert a list of all orders, add a new group G3 at the same level as group G2.

image

Also note that a diagram showing the arrangement of data groups is generated on the right side of the editor.

The result of the operator’s processing will be the following text:

Note that you can quickly modify the report by changing the position of group G3 so that it becomes a child group of G2. This will result in the orders being grouped by year.

image

The generated text will be as follows:

It is also possible to quickly change the entire format, for example to an XML format.

image

Result of the operation:

The output bus of the component with the text format defined as shown above will contain only a single record with one column, file_data.

If we modify the above example so that the first group contains year-related data, the output bus will contain as many records as there are years, and each record will include the fields used in the first group as well as the formatted text.

image

For the data above, we will obtain two records with the text stored in the file_data.

Orders report

Year: 2024
Amount of orders: 1
Gross total in year: 48,00

List of Orders:
####################################################################

Order year: 2024
Order nr: 1
Customer: Company Id 6
Order gross total: 48
--------------------------------------------------------------------