Add Table Column

Append a column to a table.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
namestr, NoneNoneName of new column
valuesAny, NoneNoneValue(s) for new column
param table:Table to modify
param name:Name of new column
param values:Value(s) for new column

The values can either be a list of values, one for each row, or one single value that is set for all rows.

Examples:

# Add empty column
Add table column    ${table}

# Add empty column with name
Add table column    ${table}    name=Home Address

# Add new column where every every row has the same value
Add table column    ${table}    name=TOS    values=${FALSE}

# Add new column where every row has a unique value
${is_first}=    Create list    ${TRUE}    ${FALSE}    ${FALSE}
Add table column    ${table}    name=IsFirst    values=${is_first}

Add Table Row

Append rows to a table.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
valuesAny, NoneNoneValue(s) for new row
param table:Table to modify
param values:Value(s) for new row

The values can either be a list of values, or a dictionary where the keys match current column names. Values for unknown keys are discarded.

It can also be a single value that is set for all columns, which is None by default.

Examples:

# Add empty row
Add table row    ${table}

# Add row where every column has the same value
Add table row    ${table}    Unknown

# Add values per column
${values}=    Create dictionary    Username=Mark    Mail=mark@robocorp.com
Add table row    ${table}    ${values}

Clear Table

Clear table in-place, but keep columns.

Arguments

Argument Type Default value Description
tableTablenullTable to clear
param table:Table to clear

Examples

Clear table    ${table}

Copy Table

Make a copy of a table object.

Arguments

Argument Type Default value Description
tableTablenullTable to copy
param table:Table to copy
return:Table object

${table_copy}= Copy table ${table}

Create Table

Create Table object from data.

Arguments

Argument Type Default value Description
dataDict[int | str, Dict | List | Tuple | NamedTuple | set], List[Dict | List | Tuple | NamedTuple | set], Table, NoneNoneSource data for table
trimboolFalseRemove all empty rows from the end of the worksheet, default False
columnsList[str], NoneNoneNames of columns (optional)

Data can be a combination of various iterable containers, e.g. list of lists, list of dicts, dict of lists.

param data:Source data for table
param trim:Remove all empty rows from the end of the worksheet, default False
param columns:Names of columns (optional)
return:Table object

See the main library documentation for more information about supported data types.

Examples

# Create a new table using a Dictionary of Lists

@{Table_Data_name}=    Create List    Mark    John    Amy
@{Table_Data_age}=    Create List    ${58}    ${22}    ${67}
&{Table_Data}=    Create Dictionary
...    name=${Table_Data_name}
...    age=${Table_Data_age}
${table}=    Create Table    ${Table_Data}

Export Table

Convert a table object into standard Python containers.

Arguments

Argument Type Default value Description
tableTablenullTable to convert to dict
with_indexboolFalseInclude index in values
as_listboolTrueExport data as list instead of dict
param table:Table to convert to dict
param with_index:
 Include index in values
param as_list:Export data as list instead of dict
return:A List or Dictionary that represents the table

Examples

${orders}=       Read worksheet as table    orders.xlsx
Sort table by column    ${orders}    CustomerId
${export}=       Export table    ${orders}
# The following keyword expects a dictionary:
Write as JSON    ${export}

Filter Empty Rows

Remove all rows from a table which have only None values.

Arguments

Argument Type Default value Description
tableTablenullTable to filter
param table:Table to filter

The filtering will be done in-place.

Examples

Filter empty rows    ${table}

Filter Table By Column

Remove all rows where column values don't match the given condition.

Arguments

Argument Type Default value Description
tableTablenullTable to filter
columnint, strnullColumn to filter with
operatorstrnullFiltering operator, e.g. >, <, ==, contains
valueAnynullValue to compare column to (using operator)
param table:Table to filter
param column:Column to filter with
param operator:Filtering operator, e.g. >, <, ==, contains
param value:Value to compare column to (using operator)

See the keyword Find table rows for all supported operators and their descriptions.

The filtering will be done in-place.

Examples:

# Only accept prices that are non-zero
Filter table by column    ${table}   price  !=  ${0}

# Remove uwnanted product types
@{types}=    Create list    Unknown    Removed
Filter table by column    ${table}   product_type  not in  ${types}

Filter Table With Keyword

Run a keyword for each row of a table, then remove all rows where the called keyword returns a falsy value.

Arguments

Argument Type Default value Description
tableTablenullTable to modify.
namestrnullKeyword name used as filter.
argsnullAdditional keyword arguments to be passed. (optional)

Can be used to create custom RF keyword based filters.

param table:Table to modify.
param name:Keyword name used as filter.
param args:Additional keyword arguments to be passed. (optional)

The row object will be given as the first argument to the filtering keyword.

Find Table Rows

Find all the rows in a table which match a condition for a given column.

Arguments

Argument Type Default value Description
tableTablenullTable to search into.
columnint, strnullName or position of the column to compare with.
operatorstrnullComparison operator used with every cell value on the specified column.
valueAnynullValue to compare against.
param table:Table to search into.
param column:Name or position of the column to compare with.
param operator:Comparison operator used with every cell value on the specified column.
param value:Value to compare against.
return:New Table object containing all the rows matching the condition.

Supported operators:

Operator Description
> Cell value is larger than
< Cell value is smaller than
>= Cell value is larger or equal than
<= Cell value is smaller or equal than
== Cell value is equal to
!= Cell value is not equal to
is Cell value is the same object
not is Cell value is not the same object
contains Cell value contains given value
not contains Cell value does not contain given value
in Cell value is in given value
not in Cell value is not in given value

Returns the matches as a new Table instance.

Examples:

# Find all rows where price is over 200
@{rows} =    Find table rows    ${table}    Price  >  ${200}

# Find all rows where the status does not contain "removed"
@{rows} =    Find table rows    ${table}    Status  not contains  removed

Get Table Cell

Get a cell value from a table.

Arguments

Argument Type Default value Description
tableTablenullTable to read from
rowint, strnullRow of cell
columnint, strnullColumn of cell
param table:Table to read from
param row:Row of cell
param column:Column of cell
return:Cell value

Examples:

# Get the value in the first row and first column
Get table cell    ${table}    0    0

# Get the value in the last row and first column
Get table cell    ${table}   -1    0

# Get the value in the last row and last column
Get table cell    ${table}   -1    -1

# Get the value in the third row and column "Name"
Get table cell    ${table}    2    Name

Get Table Column

Get all values for a single column in a table.

Arguments

Argument Type Default value Description
tableTablenullTable to read
columnint, strnullColumn to read
param table:Table to read
param column:Column to read
return:List of the rows in the selected column

Examples

${emails}=    Get table column    ${users}    E-Mail Address

Get Table Dimensions

Return table dimensions, as (rows, columns).

Arguments

Argument Type Default value Description
tableTablenullTable to inspect
param table:Table to inspect
return:Two integer values that represent the number of rows and columns

Examples

${rows}  ${columns}=    Get table dimensions    ${table}
Log    Table has ${rows} rows and ${columns} columns.

Get Table Row

Get a single row from a table.

Arguments

Argument Type Default value Description
tableTablenullTable to read
rowint, strnullRow to read
as_listboolFalseReturn list instead of dictionary
param table:Table to read
param row:Row to read
param as_list:Return list instead of dictionary
return:Dictionary or List of table row

Examples:

# returns the first row in the table
${first}=    Get table row    ${orders}

# returns the last row in the table
${last}=      Get table row    ${orders}    -1    as_list=${TRUE}

Get Table Slice

Return a new Table from a range of given Table rows.

Arguments

Argument Type Default value Description
tableTablenullTable to read from
startint, str, NoneNoneEnd index (exclusive)
endint, str, NoneNone
param table:Table to read from
param start:Start index (inclusive)
param start:End index (exclusive)
return:Table object of the selected rows

If start is not defined, starts from the first row. If end is not defined, stops at the last row.

Examples:

# Get all rows except first five
${slice}=    Get table slice    ${table}    start=5

# Get rows at indexes 5, 6, 7, 8, and 9
${slice}=    Get table slice    ${table}    start=5    end=10

# Get all rows except last five
${slice}=    Get table slice    ${table}    end=-5

Group Table By Column

Group a table by column and return a list of grouped Tables.

Arguments

Argument Type Default value Description
tableTablenullTable to use for grouping
columnint, strnullColumn which is used as grouping criteria
param table:Table to use for grouping
param column:Column which is used as grouping criteria
return:List of Table objects

Examples

# Groups rows of matching customers from the customer column

@{groups}=    Group table by column    ${orders}    customer
# An example of how to use the List of Tables once returned
FOR    ${group}    IN    @{groups}
    # Process all orders for the customer at once
    Process order    ${group}
END

Map Column Values

Run a keyword for each cell in a given column, and replace its content with the return value.

Arguments

Argument Type Default value Description
tableTablenullTable to modify.
columnint, strnullColumn to modify.
namestrnullMapping keyword name.
argsnullAdditional keyword arguments. (optional)

Can be used to easily convert column types or values in-place.

param table:Table to modify.
param column:Column to modify.
param name:Mapping keyword name.
param args:Additional keyword arguments. (optional)

The cell value will be given as the first argument to the mapping keyword.

Examples:

# Convert all columns values to a different type
Map column values    ${table}    Price    Convert to integer

# Look up values with a custom keyword
Map column values    ${table}    User     Map user ID to name

Merge Tables

Create a union of two tables and their contents.

Arguments

Argument Type Default value Description
tablesTablenullTables to merge
indexstr, NoneNoneColumn name to use as index for merge
param tables:Tables to merge
param index:Column name to use as index for merge
return:Table object

By default rows from all tables are appended one after the other. Optionally a column name can be given with index, which is used to merge rows together.

Examples

For instance, a name column could be used to identify unique rows and the merge operation should overwrite values instead of appending multiple copies of the same name.

Name Price
Egg 10.0
Cheese 15.0
Ham 20.0
Name Stock
Egg 12.0
Cheese 99.0
Ham 0.0
${products}=    Merge tables    ${prices}    ${stock}    index=Name
FOR    ${product}    IN    @{products}
    Log many
    ...    Product: ${product}[Name]
    ...    Price: ${product}[Price]
    ...    Stock: ${product}[Stock]
END

Pop Table Column

Remove column from table and return it.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
columnint, str, NoneNoneColumn to remove
param table:Table to modify
param column:Column to remove
return:Dictionary or List of the removed, popped, column

Examples:

# Remove column from table and discard it
Pop table column    ${users}   userId

# Remove column from table and iterate over it
${ids}=    Pop table column    ${users}    userId
FOR    ${id}    IN    @{ids}
    Log    User id: ${id}
END

Pop Table Row

Remove row from table and return it.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
rowint, str, NoneNoneRow index, pops first row if none given
as_listboolFalseReturn list instead of dictionary
param table:Table to modify
param row:Row index, pops first row if none given
param as_list:Return list instead of dictionary
return:Dictionary or List of the removed, popped, row

Examples:

# Pop the firt row in the table and discard it
Pop table row    ${orders}

# Pop the last row in the table and store it
${row}=      Pop table row    ${data}    -1    as_list=${TRUE}

Read table from CSV

Read a CSV file as a table.

Arguments

Argument Type Default value Description
pathstrnullPath to CSV file
headerbool, NoneNoneCSV file includes header
columnsList[str], NoneNoneNames of columns in resulting table
dialectstr, Dialect, NoneNoneFormat of CSV file
delimitersstr, NoneNoneString of possible delimiters
column_unknownstrUnknownColumn name for unknown fields
encodingstr, NoneNoneText encoding for input file, uses system encoding by default
param path:Path to CSV file
param header:CSV file includes header
param columns:Names of columns in resulting table
param dialect:Format of CSV file
param delimiters:
 String of possible delimiters
param column_unknown:
 Column name for unknown fields
param encoding:Text encoding for input file, uses system encoding by default
return:Table object

By default attempts to deduce the CSV format and headers from a sample of the input file. If it's unable to determine the format automatically, the dialect and header will have to be defined manually.

Builtin dialect values are excel, excel-tab, and unix, and header is boolean argument (True/False). Optionally a set of valid delimiters can be given as a string.

The columns argument can be used to override the names of columns in the resulting table. The amount of columns must match the input data.

If the source data has a header and rows have more fields than the header defines, the remaining values are put into the column given by column_unknown. By default it has the value "Unknown".

Examples:

# Source dialect is deduced automatically
${table}=    Read table from CSV    export.csv
Log   Found columns: ${table.columns}

# Source dialect is known and given explicitly
${table}=    Read table from CSV    export-excel.csv    dialect=excel
Log   Found columns: ${table.columns}

Rename Table Columns

Renames columns in the Table with given values. Columns with name as None will use the previous value.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
namesList[str | None]nullList of new column names
strictboolFalseIf True, raises ValueError if column lengths do not match
param table:Table to modify
param names:List of new column names
param strict:If True, raises ValueError if column lengths do not match

The renaming will be done in-place.

Examples:

# Initially set the column names
${columns}=    Create list   First  Second  Third
Rename table columns    ${table}    ${columns}
# First, Second, Third

# Update the first and second column names to Uno and Dos
${columns}=    Create list   Uno  Dos
Rename table columns    ${table}    ${columns}
# Uno, Dos, Third

Set Row As Column Names

Set existing row as names for columns.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
rowint, strnullRow to use as column names
param table:Table to modify
param row:Row to use as column names

Examples

# Set the column names based on the first row
Set row as column names    ${table}    0

Set Table Cell

Set a cell value in a table.

Arguments

Argument Type Default value Description
tableTablenullTable to modify to
rowint, strnullRow of cell
columnint, strnullColumn of cell
valueAnynullValue to set
param table:Table to modify to
param row:Row of cell
param column:Column of cell
param value:Value to set

Examples:

# Set the value in the first row and first column to "First"
Set table cell    ${table}    0    0       First

# Set the value in the last row and first column to "Last"
Set table cell    ${table}   -1    0       Last

# Set the value in the last row and last column to "Corner"
Set table cell    ${table}   -1    -1       Corner

# Set the value in the third row and column "Name" to "Unknown"
Set table cell    ${table}    2    Name    Unknown

Set Table Column

Assign values to a column in the table.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
columnint, strnullColumn to modify
valuesAnynullValue(s) to set
param table:Table to modify
param column:Column to modify
param values:Value(s) to set

The values can either be a list of values, one for each row, or one single value that is set for all rows.

Examples:

# Set different value for each row (sizes must match)
${ids}=    Create list    1  2  3  4  5
Set table column    ${users}    userId    ${ids}

# Set the same value for all rows
Set table column    ${users}    email     ${NONE}

Set Table Row

Assign values to a row in the table.

Arguments

Argument Type Default value Description
tableTablenullTable to modify
rowint, strnullRow to modify
valuesAnynullValue(s) to set
param table:Table to modify
param row:Row to modify
param values:Value(s) to set

The values can either be a list of values, or a dictionary where the keys match current column names. Values for unknown keys are discarded.

It can also be a single value that is set for all columns.

Examples:

${columns}=  Create list     One  Two  Three
${table}=    Create table    columns=${columns}

${values}=   Create list     1  2  3
Set table row    ${table}    0    ${values}

${values}=   Create dictionary    One=1  Two=2  Three=3
Set table row    ${table}    1    ${values}

Set table row    ${table}    2    ${NONE}

Sort Table By Column

Sort a table in-place according to column.

Arguments

Argument Type Default value Description
tableTablenullTable to sort
columnint, strnullColumn to sort with
ascendingboolTrueTable sort order
param table:Table to sort
param column:Column to sort with
param ascending:
 Table sort order

Examples:

# Sorts the order_date column ascending
Sort table by column    ${orders}    order_date

# Sorts the order_date column descending
Sort table by column    ${orders}    order_date    ascending=${FALSE}

Table Head

Return first count rows from a table.

Arguments

Argument Type Default value Description
tableTablenullTable to read from
countint5Number of lines to read
as_listboolFalseReturn list instead of Table
param table:Table to read from
param count:Number of lines to read
param as_list:Return list instead of Table
return:Return Table object or List of the selected rows

Examples

# Get the first 10 employees
${first}=    Table head    ${employees}    10

Table Tail

Return last count rows from a table.

Arguments

Argument Type Default value Description
tableTablenullTable to read from
countint5Number of lines to read
as_listboolFalseReturn list instead of Table
param table:Table to read from
param count:Number of lines to read
param as_list:Return list instead of Table
return:Return Table object or List of the selected rows

Examples

# Get the last 10 orders
${latest}=    Table tail    ${orders}    10

Trim Column Names

Remove all extraneous whitespace from column names.

Arguments

Argument Type Default value Description
tableTablenullTable to filter
param table:Table to filter

The filtering will be done in-place.

Examples

# This example will take colums such as:



Trim column names     ${table}

Trim Empty Rows

Remove all rows from the end of a table which have only None as values.

Arguments

Argument Type Default value Description
tableTablenullTable to filter
param table:Table to filter

The filtering will be done in-place.

Examples

Trim empty rows    ${table}

Write table to CSV

Write a table as a CSV file.

Arguments

Argument Type Default value Description
tableTablenullTable to write
pathstrnullPath to write to
headerboolTrueWrite columns as header to CSV file
dialectstr, DialectExcelThe format of output CSV
encodingstr, NoneNoneText encoding for output file, uses system encoding by default
delimiterstr, None,Delimiter character between columns
param table:Table to write
param path:Path to write to
param header:Write columns as header to CSV file
param dialect:The format of output CSV
param encoding:Text encoding for output file, uses system encoding by default
param delimiter:
 Delimiter character between columns

Builtin dialect values are excel, excel-tab, and unix.

Examples

${sheet}=    Read worksheet as table    orders.xlsx    header=${TRUE}
Write table to CSV    ${sheet}    output.csv