Skip to main content

Robot Task Activities - List Variable​

The List Variable activities create, load, change and save List Variables, which are User Variables that hold rows and columns.

A List Variable created by these activities appears with the User Variables in the Variables window. List Variables are the usual way a Robot Task processes a data file: load the file into a list, loop through the rows with a For Each loop, and write the results back into the list.

The List Variable category in the activity list, with the List, Column and Row activities

Most of these activities are set up in a settings window: click Click to open settings on the activity. Several activities write their outcome to a Result property in the Properties pane. The value is an RPA variable, available while the Robot Task runs, that later activities read as {RPA(VariableName)}.

Row numbers start at 1. An activity fails if the list or column it names does not exist, if a row number is out of range, or if the list or column it would create already exists, unless the activity says otherwise below.


List activities​

List - Create​

Creates a new List Variable with the rows and columns set in the Create List window. The activity fails if a variable with that name already exists.

The List Variable Create activity with the Click to open settings link

The Create List window, with the Variable name field, the buttons to add and delete rows and columns and to edit a column, and the list grid

  • Variable name: the name of the new list
  • The row buttons add a row and delete the selected row
  • The column buttons add a column, delete the selected column and edit the selected column. Adding or editing a column opens the column settings

Drag a column to change the order of the columns.

Column settings

The Add Column window, with the Name and Variable type fields

  • Name: the column name
  • Variable type: the data type of the column, for example "Int32" or "String"

List - Update​

Replaces the content of a List Variable with the rows and columns set in the activity. If the variable does not exist, the activity creates it. The settings are the same as for List - Create.

warning

List - Update replaces all the rows and columns of an existing list. Rows added to the list since it was created are lost.


List - Delete​

Deletes a List Variable. Choose the list in Variable name.

warning

List Variables are User Variables, so the deleted list is gone for every Job that uses it. To keep a copy, run List - Duplicate or List - Save first.

The Delete List window, with the Variable name field


List - Clear​

Removes the content of a List Variable but keeps the variable. The settings are the same as for List - Delete.


List - Set value​

Sets the value of one cell of a List Variable.

The Set value window, with the List name, Row, Column and Value fields

  • List name: the list to change
  • Row: the row number
  • Column: the column
  • Value: the value to set. For an integer, double or Boolean column, the activity fails if the value cannot be converted to that type

This is the activity that marks a record as processed inside a loop. Set Row to the loop iteration variable and Column to a status column, and place the activity at the very end of the loop body. See Data Processing & Logging.


List - Exists​

Checks whether a List Variable exists. The settings are the same as for List - Delete.

  • Result: in the Properties pane, the name of the RPA variable that receives "True" or "False"

List - Duplicate​

Copies a List Variable to a new List Variable.

The Duplicate List window, with the Source variable name and New variable name fields

  • Source variable name: the list to copy
  • New variable name: the name of the new list

List - Merge​

Merges List Variables into a new List Variable.

The Source list variables list with two lists checked

The Merge List window, with the Source list variables and New variable name fields

  • Source list variables: check the lists to merge
  • New variable name: the name of the new list that receives the merged rows

List - Rename​

Renames a List Variable.

The Rename List window, with the Source variable name and New variable name fields

  • Source variable name: the list to rename
  • New variable name: the new name

List - Reverse​

Reverses the order of the rows of a List Variable.

The Reverse List window, with the Variable name field

  • Variable name: choose a list or type its name. Accepts variables

List - Shuffle​

Puts the rows of a List Variable in random order. The settings are the same as for List - Reverse.


List - Sort​

Sorts the rows of a List Variable by one column.

The Sort List window, with the Variable name, By column and Sort direction fields

  • Variable name: choose a list or type its name
  • By column: the column to sort by
  • Sort direction: "Asc" or "Desc"

List - Subtract​

Creates a new List Variable from the rows of the first list, without the rows that are also in the second list. A row that appears more than once in the first list appears once in the result.

The Subtract List window, with the First list variable, Second list variable and Result variable name fields

  • First list variable: choose a list or type its name
  • Second list variable: choose the list whose rows are taken away
  • Result variable name: the name of the new list. The activity fails if it already exists

List - Distinct​

Removes duplicate rows from a List Variable.

The Distinct List window, with the Variable name and Column name fields

  • Variable name: choose a list or type its name
  • Column name: the column whose values must be unique. When it is empty, only rows that are the same in every column are removed

When Column name is set, only the first row for each value of that column is kept.

warning

The column name must match exactly, including case. If no column has that name, the activity does not fail: it keeps only the first row of the list. Run List - Duplicate first if the original rows are needed.


List - Save​

Saves a List Variable to a file or to the clipboard as delimited text.

The Save List window, with the Variable name, Include column names, Field separator, Text qualifier, Line break, Save to and File path fields

  • Variable name: choose a list or type its name
  • Include column names: write the column names as the first line
  • Field separator: the character between columns, for example "Tab" or "Comma"
  • Text qualifier: the character around values
  • Line break: the line break to write, for example "CrLf"
  • Save to: "File", to write to File path, or "Clipboard"
  • File path: the file the list is written to when Save to is "File". Click Browse to choose it
warning

With Save to set to "File", the activity replaces a file that already exists at File path without asking. Include a variable in the path so that each run writes a new file, for example C:\Testing\RPA\{JOB(Active|Name)}_{DATEFORMAT(yyyy-MM-dd)}.csv.


List - Get Info​

Gets information about a List Variable and writes it to an RPA variable as text.

The Get List Info window, with the Variable name, Info type and Column name fields

  • Variable name: choose a list or type its name
  • Info type: the information to get:
    • "RowCount": the number of rows
    • "ColumnCount": the number of columns
    • "ColumnType": the data type of the column in Column name
  • Column name: the column, used when Info type is "ColumnType"
  • Result: in the Properties pane, the name of the RPA variable that receives the information

Read the result in a later activity with {RPA(VariableName)}. A common use is setting the end value of a For loop from a "RowCount" result. The For loop stops before its To Y value, so add 1 to the row count when the loop starts at 1.


List - Load​

Creates a List Variable from a delimited text file, read as UTF-8. The Load List into Variable window has these settings:

  • Variable name: the name of the List Variable to create
  • Recreate if exists: replace a List Variable with that name if it exists. When cleared, the activity fails if the variable exists
  • File path: the file to read. Click Browse to choose it
  • Include column names, Field separator and Text qualifier: the format of the file, in the File format group. Click Refresh preview to see how the file is read

Column activities​

Column - Create​

Adds a new column to a List Variable.

The Create Column window, with the List name, Column name and Column type fields

  • List name: choose a list or type its name
  • Column name: the name of the new column
  • Column type: the data type of the column

This is the activity that adds a status column to a loaded data file before it is processed. See Data Processing & Logging.


Column - Delete​

Deletes a column of a List Variable.

The Delete Column window, with the Variable name and Column name fields

  • Variable name: choose a list or type its name
  • Column name: the column to delete

Column - Duplicate​

Copies a column of a List Variable to a new column.

The Duplicate Column window, with the Variable name, Column name and New column name fields

  • Variable name: choose a list or type its name
  • Column name: the column to copy
  • New column name: the name of the new column

Column - Clear​

Clears the values of a column of a List Variable.

The Clear Column window, with the Variable name and Column name fields

  • Variable name: choose a list or type its name
  • Column name: the column whose values are cleared

Column - Exists​

Checks whether a column exists in a List Variable. The settings window is like the one for Column - Clear.

  • Result: in the Properties pane, the name of the RPA variable that receives "True" or "False"

Column - Move​

Moves a column of a List Variable to a new position.

The Move Column window, with the Variable name, Column name, Move type, Right of column and Index fields

  • Variable name: choose a list or type its name
  • Column name: the column to move
  • Move type: how the column is moved
    • "Left": to the left of the column in Left of column
    • "Right": to the right of the column in Right of column
    • "FirstColumn": to the first position
    • "LastColumn": to the last position
    • "Specific": to the position in Index
  • Left of column or Right of column: the column to place it next to, when Move type is "Left" or "Right"
  • Index: the position to move to, when Move type is "Specific"

The Move type list, with Left, Right, FirstColumn, LastColumn and Specific


Column - Rename​

Renames a column of a List Variable.

The Rename Column window, with the Variable name, Column name and New column name fields

  • Variable name: choose a list or type its name
  • Column name: the column to rename
  • New column name: the new name

Row activities​

Row - Add​

Adds a row at the end of a List Variable.

The Add Row window, with the Variable name field and a row grid for the values

  • Variable name: choose a list or type its name
  • Row: the values of the new row

Row - Insert​

Inserts a row at a position in a List Variable.

The Insert Row window, with the Variable name and Row index fields and a row grid for the values

  • Variable name: choose a list or type its name
  • Row index: the row number to insert at
  • Row: the values of the new row

Row - Update​

Changes the values of a row of a List Variable.

The Update Row window, with the Variable name and Row index fields and a row grid for the values

  • Variable name: choose a list or type its name
  • Row index: the row number to change
  • Row: the new values of the row

Row - Delete​

Deletes a row of a List Variable.

The Delete Row window, with the Variable name and Row index fields and the rows of the list

  • Variable name: choose a list or type its name
  • Row index: the row number to delete. Type it, or select the row in Row
  • Row: the rows of the list, to select the row to delete

Row - Clear​

Clears the values of a row of a List Variable. The settings are the same as for Row - Delete.


Row - Move​

Moves a row of a List Variable to a new position.

The Move Row window, with the Variable name, Row index, Move type and Move down to fields

  • Variable name: choose a list or type its name
  • Row index: the row number to move
  • Move type: how the row is moved
    • "Up": up by the number in Move up to
    • "Down": down by the number in Move down to
    • "FirstRow": to the first position
    • "LastRow": to the last position
    • "Specific": to the row number in Move to index
  • Move up to or Move down to: the number of positions to move, when Move type is "Up" or "Down"
  • Move to index: the row number to move to, when Move type is "Specific"

The Move type list, with Up, Down, FirstRow, LastRow and Specific


Reading a cell from a List Variable​

Outside these activities, a cell is read from a List Variable with the USERVAR variable function and its GetCell operation:

{USERVAR(ListName|GetCell|RowNumber|ColumnNameOrNumber|IncludeColumns)}

Combined with the loop iteration variable, this reads the cell of the record being processed:

{USERVAR(lvDateReformat|GetCell|{RPALOOP(a381|Iterations)}|Date|false)}

Variable functions can be nested, so the value can be changed in the same expression. Here the cell is trimmed of surrounding spaces:

{STRING(Trim|{USERVAR(lvDateReformat|GetCell|{RPALOOP(a381|Iterations)}|Date|false)})}

The Variables window lists the other List Variable operations, such as row and column counts, minimum and maximum values, and duplicate checks.


Tips​

  • Name List Variables with an lv prefix, for example lvCustomerRecords. A Task with dozens of variables is much easier to work with when the kind of variable is visible in the name
  • Add a status column with Column - Create right after loading a data file, and mark rows with List - Set value at the end of each loop iteration. That records which rows completed if the Task fails partway through
  • Run List - Save at every point where an error can be raised, not only at the end of the Task, so that the status column survives a failure
  • Use List - Get Info with "RowCount" to set a For loop's end value instead of typing the number of records, and add 1 when the loop starts at 1
  • List - Distinct with Column name empty removes rows that are the same in every column. Set a column name to remove duplicates by a key such as an account number
  • Use List - Duplicate before a change such as List - Distinct or List - Sort if the original order is needed later