Example of using Split action
- Updated: 2023/08/04
Example of using Split action
In this example, you will build a bot to read a CSV file, split a specified string into multiple strings.
Prerequisites
Before you start building the bot, create a file in .CSV format using
the data in the following table and save it as
String_datatable.csv
Name | Location | Joining date |
---|---|---|
Savio | Bangalore | 26-Jun-21 |
Rene | Bangalore | 15-Oct-21 |
Procedure
- Create a bot.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: String_split.
- Click Create and Edit.
- On the left panel, click Automation.
- Open and read data from the CSV file.
- Double-click or drag the action.
- From the File option, in the Desktop file field, click Browse to select your file.
- Select the Sheet contains a header checkbox.
- Open the file in Read-write mode.
- In the Create Excel session field, select Local session.
- Double-click or drag the action.
- From the Cell option tab, select From specific cell and enter C2 in the Cell address field.
- From the Read option tab, select Read visible text in cell option.
- In the Session name field, enter the session that you used to open the file.
- In the Assign value to the variable field, click the Create variable icon to create a variable.
- On the Create variable window, enter list_outputdata in the Name field.
- Click Create and select.
- Double-click or drag the action to close the .txt file.
- In the Session name field, enter the session name that you used in the Open action to open the file.
- To print the values of the specified row, double-click or drag the Message box
action. In the Enter
the message to display field, enter $list_outputdata[0]$.
When you run the bot, the bot displays the string in row C2 as 26-Jun-21.
- To split the specified string into multiple strings, double-click or drag the
action.
- In the Source string field, enter $list_outputdata[0]$
- In the Delimiter field, enter -.
- From the Delimiter is tab, select Not case sensitive.
- From the Split into substrings tab, select All possible
- In the Assign value to the variable field, click the Create variable icon to create a variable.
- On the Create variable window, enter substrings_split in the Name field.
- Click Create and select.
- To print the values, double-click or drag the Message
box
action. In the Enter
the message to display field, enter the following
data:
Date is $substrings_split[0]$
Month is $substrings_split[1]$
Year is $substrings_split[2]$
- Click Save and then Run.
The bot splits the specified string into multiple substrings and displays the output as follows: