Example 1
Example 1
Introduction
The goal of this example is to read an excel file to a data-list, then repeat over the data-list and for each data-item select the ID
column text and perform a check on the 7th
digit in order to determine if the gender of the person is Male of Female. The gender is then added to the data-list and written to a new excel file.
Read excel file to data-list
Excel can be automated with the use of the Read Excel file to data-list command to read an excel files data into a data-list.
The Read Excel file to data-list command settings can be edited to have the Header options
, Fields to import
, Filepath
, Worksheet name
, and Delay
filled out manually or have the appropriate data types linked.
Repeat over data-list
The data-list can now be repeated over to access each individual data-item with the Repeat over data-list command and then use Select data-field from data-item command to select the ID
field for each repeat.
Select characters from text
The Select characters from text command will then be used to extract the 7th character of the ID
text value.
Convert text to number
When number is
The ID
text is then converted into number with the Convert text to number command and then use the When number is command to determine if the number is less than or equals
to 4
.
If the number is not less then or equals
to 4
, then another When number is command is used to determine if the number is less than or equals
to 9
.
Set text value
If the number is less then or equals
to 4
text is set to Female
, if the number is less than or equals
to 9
text is set to Male
.
Update data-item
The new text is then updated into the Gender
column of that data-item with the use of the Update data-item command.
Add data-item to data-list
The data-item
is then added to a new data-list
via an Internal Variable and the Append data-item to data-list.
Set data-list value
After the loop is over the Set data-list value command is used to set the previously compiled data-list
with all of the Gender
values.
Write data-list to Excel file
The data-list
is then written to a new excel file with the Write data-list to Excel file