RPA.Tables
Tables is a library for manipulating tabular data inside Robot Framework.
It can import data from various sources and apply different operations to it. Common use-cases are reading and writing CSV files, inspecting files in directories, or running tasks using existing Excel data.
Import types
The data a table can be created from can be of two main types:
- An iterable of individual rows, like a list of lists, or list of dictionaries
- A dictionary of columns, where each dictionary value is a list of values
For instance, these two input values:
Would both result in the following table:
Index | Name | Age |
---|---|---|
0 | Mark | 58 |
1 | John | 22 |
2 | Adam | 67 |
Indexing columns and rows
Columns can be referred to in two ways: either with a unique string name or their position as an integer. Columns can be named either when the table is created, or they can be (re)named dynamically with keywords. The integer position can always be used, and it starts from zero.
For instance, a table with columns "Name", "Age", and "Address" would allow referring to the "Age" column with either the name "Age" or the number 1.
Rows do not have a name, but instead only have an integer index. This index also starts from zero. Keywords where rows are indexed also support negative values, which start counting backwards from the end.
For instance, in a table with five rows, the first row could be referred to with the number 0. The last row could be accessed with either 4 or -1.
Examples
Robot Framework
The Tables library can load tabular data from various other libraries and manipulate it inside Robot Framework.
Python
The library is also available directly through Python, where it is easier to handle multiple different tables or do more bespoke manipulation operations.