Example of using Custom column option in Data Table package
- Updated: 2023/04/20
Example of using Custom column option in Data Table package
In this example, you will build a bot to read a CSV file, assign it to a data table variable, and then modify the table by adding a new column. Use the Custom column option in the Data Table package to insert columns at a specified index.
Prerequisites
Before you start building the bot, create a file in .CSV format using
the data in the following table and save it as
Data_table_input.csv.
Name | Company | Availability |
---|---|---|
Rene | AA | FALSE |
Leote | DG | FALSE |
Shane | CV | FALSE |
Procedure
-
Create a bot.
-
Open and read data from the CSV file.
-
Insert a new column of data type String to the existing
table.
- Double-click or drag the action.
- In the Destination table field, select the variable TableFromCSV.
- From the Insert column at index field, select last index.
- From the Insert column option, select Custom column.
- In the Column name field, enter Address.
- In the Column type field, select the data type as String.
- In the Default value field, enter Bangalore.
-
Write the new data to the CSV file.
- Double-click or drag the action.
- In the Data table name field, select TableFromCSV variable.
- In the Enter file name field, select the CSV file that you have saved on your desktop.
- From the When writing field, select the Overwrite existing file option.
-
Open the CSV file to view the updated data.
- Double-click or drag the action.
- In the File tab, click Browse to select your file.
- Select the Sheet contains a header check box.
- Select the Read-write mode option to enable reading and editing of the file.
- Double-click or drag the action.
- Enter a delay time of 5 seconds.
-
Close the CSV file.
- Double-click or drag the action.
- Select the Save changes when closing file option.
- In the Session name field, select the name of the session that you used to open the CSV file.
-
Insert a new column of data type DateTime to the existing
table.
- Double-click or drag the action.
- In the Destination table field, select the variable TableFromCSV.
- From the Insert column at index field, select specific index and specify the index in the text field.
- From the Insert column option, select Custom column.
- In the Column name field, enter Date of joining.
-
Open the CSV file to view the updated data.
- Double-click or drag the action.
- In the File tab, click Browse to select your file.
- Select the Sheet contains a header check box.
- Select the Read-write mode option to enable reading and editing of the file.
- Double-click or drag the action.
- Enter a delay time of 5 seconds.
-
Close the CSV file.
- Double-click or drag the action.
- Select the Save changes when closing file option.
- In the Session name field, select the name of the session that you used to open the CSV file.