What follows is a video describing how to perform data conversion in robots.
Sometimes when designing a robot we need to convert some text or numbers using simple or complex conversion rules. The question is: how do we do this easily in Design Studio?
In this video we will be talking about this field.
It may not look like much but it is actually a very powerful tool when building robots and it pops up everywhere in the Design Studio interface.
The field is called a Data Converter List, and for now let's regard it as a black box. It may take an input in the form of a value from, for example, a variable or extracted text; but input is not a strict necessity. The input, if present, is given by the placement of the Data Converter List and is always stated somewhere above it.
The Data Converter List has exactly one output, which is either stored in a variable or handled otherwise below.
In short, a Data Converter List is used to manipulate text and numbers within robots, but although it is possible to perform both text and number manipulation with the Data Converter List, input and output is strictly speaking always interpreted as text.
Some use examples include extracting the name from an email address,..
..multiplying a number by two,..
or adding three days and two hours to a given date.
Let's take a look at the interior.
As the name Data Converter List implies, the field contains a list which you can add a variety of different converters to by clicking the plus icon. These converters all manipulate the input in some way.
Here is an example where we have the Kapow Software website URL as the input. We start with no converters in the converter list so the output is the same as the input. By adding the Extract converter we can extract the middle part of the URL. Don't worry about how the converters work for now. We will get back to that.
Then we can add a converter which converts the text to upper case.
The two converters are then chained together in series so the output of the first flows into the input of the second.
The order in which the converters are listed represents the order in which they are performed. The order can be changed by clicking the arrows. In this case it makes no difference to the end result.
Converters can be deleted by clicking the minus.
Clicking the pen and paper icon opens a window used to configure the converter. This window also opens when the converter is first added to the list.
The Converter configuration window always contains the two important fields Test Input and Test Output which, as the names imply, demonstrate the input and output from the given converter.
Learn how to use the different converters by clicking the question mark in the configuration window. Clicking it opens the documentation. Here you can also read about Expressions and Patterns. Knowing how to use these is an invaluable skill when working with data converters.
For example if you need to use mathematical operations to manipulate a number, expressions are needed. I can multiply the input by two by using the converter called evaluate expression. Let's take a closer look at the expression used to perform this operation. It converts the input to a number and then multiplies it by two. Remember that all input and output from converters is text so we need to convert the input to a number before applying any mathematical operations to it.
Here are some examples of the use of data converter lists in Design Studio.
The data converter list you will find the most useful is probably the one located in the Extract step action. It allows you to convert any extracted text before storing it in a variable.
Let me show you an example of how to use this.
I'm in the process of creating a robot which extracts job offerings from LinkedIn. For now it simply loads the page and loops through the tags which contain job descriptions. I would like to extract the location of each job but it's stated in the same tag as two other pieces of information, namely company name and date. The three pieces of information are only separated by hyphens.
I start by extracting the entire text into a variable called location. I then select the Extraction step in the robot view and add an extract converter to the data converter list of the extraction step. The extract converter uses a pattern to decide which part of the input should be extracted and used as output. In this case we want to extract everything within the first and the second hyphen.
After finishing the pattern we can see that the Test Output field reflects the text we wanted to extract.
Selecting the end step and iterating through the loop we can see that the location has successfully been extracted from each of the job descriptions.
As you can see, converters are quickly implemented and extremely effective.
Lastly I'll give you a couple of tips on the use of data converters.
Tip 1: Many fields in Design Studio can be changed to data converter lists. This may be done by choosing Converters from the Value Selector located at the right side of the field.
Tip 2: One of the most useful converters is the Replace Pattern converter. It combines expressions and patterns to provide powerful text manipulation.
Tip 3: In addition to the restricted one input of data converter lists, additional variables can be fetched by using expressions. This allows us to combine data from several variables.
Thank you for watching this short introduction to data converters.
For more information on the available converters, consult the documentation at help.kapowsoftware.com under References >> Design Studio>>Data Converters.