Skip to main content

How to update Data Table rows?

· 5 min read
Burcu Evren

Data Table nodes are here to make your life easier when it comes to handling data. These nodes have been designed for common operations such as adding/removing columns and rows, merging tables, and efficiently sorting data.

In this guide, we'll show you how to use Data Table nodes to effortlessly replace values in rows and make changes to numeric data.

How to Setup?

To begin, Login to your Robomotion workspace. If you haven't registered yet, you can create your workspace from the provided link. Once you have access to your workspace, you can proceed by utilizing the Data Table package to replace values. For any operations involving numerical data, feel free to employ the Number package.

About the Data Table Package

The DataTable Package is designed to empower automation developers, making data transformations a breeze. It comprises various nodes tailored to different data manipulation tasks, with one particularly significant node being the 'Replace Values' node. This node is dedicated to altering the values you intend to modify.

On the other hand, the Number package serves various purposes, including assigning values, decreasing/increasing values, and generating random values.

Building Blocks for Successful Flow

To utilize the 'Replace Values' and 'Data Table to CSV' nodes, you'll need to download the 'Data Table' package. Similarly, if you intend to use the 'Decrement' node, you must download the 'Number' package.

To obtain both the 'Data Table' and 'Number' packages, simply navigate to the 'Packages' menu and follow the download instructions

Packages Icon

Install icons for 'Data Table' and 'Number' Packages

Node Overview

  • Inject: This node initializes the flow.
  • Function: In this node, variables, objects, etc., to be used in the flow are defined.
  • Replace Values: This node replaces the desired value in a table with a new one.
  • For Each: The for-each loop is used to iterate through elements of arrays and collections (like Array). It is also known as the enhanced for loop.
  • Decrement: This node is used to decrease a numeric value. The input must be an integer.
  • Goto: To ensure flow continuity, this node provides the connection and routing between the nodes used to ensure process repetition when an error is received. When the flow reaches this node, it continues from wherever it was redirected.
  • Label: This node holds the redirection of the 'Goto' node and continues the flow from where it is located.
  • Data Table to CSV: This node converts a table to a CSV file. The path to the CSV file and the table must be provided as input.
  • Stop: This node is used to halt the flow.

Flow Steps

  1. Access to the workspace is granted through the instructions outlined in the "How to Set Up" section.
  2. ‘Inject’ node is used to initialize the flow.
  3. Within the 'Prepare Data Table' function node, the variables msg.csv_path and msg.table are defined. The msg.csv_path variable is utilized to specify the path for writing the modified table's output to a CSV file. It is essential to define the path for this variable. On the other hand, the msg.table variable is employed to designate the table to be updated.
msg.csv_path = "C:\\Robomotion\\Templates\\myCSV.csv"; //The path to the CSV file where the output will be saved.

msg.table = {
columns: ["Name", "Surname", "Age"],
rows: [{
Name: 'Jack',
Surname: 'Smith',
Age: 21
},
{
Name: 'Harry',
Surname: '',
Age: 30
},
{
Name: 'Charlie',
Surname: '',
Age: 50
}
]
};

return msg;
  1. In the 'Replace Surnames' node, the data to be modified is replaced throughout the entire table. In this flow, all values that are defined as empty in the 'Prepare Data Table' function node are substituted with '-'.

Replace Values Node Details

  1. The 'For Each' node iterates through all elements of the msg.table.rows array. The msg.table.rows variable is used to access rows in the table, with each element being defined within the msg.item variable.

‘For Each’ Node Details

  1. The 'Decrement' node decreases the specified value for the specified element. In this example, it will subtract 2 from the age value that has been defined.

‘Decrement’ Node Details

  1. In the 'Replace Ages' node, the reduced value is defined as the new value and then substituted for the old age value.

‘Replace Values’ Node Details

  1. The 'Go To Next Item' node is employed to revisit each element of the array defined in the 'For Each' node. The flow is redirected to the 'Label Next Item' node. This loop persists until all elements have been processed.
  2. Once the loop is concluded, the final table is saved to the previously specified CSV file.

Update Data Table Rows Flow

Here you can access the complete flow by clicking on the following link:

https://casestudies.robomotion.io/designer/shared/BkJTR5cGZ21Y97HgWKohhe