Add Table Column
Append a column to a table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
name | None | ||
values | None |
param table: | table to modify |
---|---|
param name: | name of new column |
param values: | row values (or single scalar value for all rows) |
Add Table Row
Append rows to a table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
row | null | ||
index | None |
param table: | table to modify |
---|---|
param row: | value for new row |
param index: | index name for new row |
Clear Table
Clear table in-place, but keep columns.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null |
param table: | table to clear |
---|
Copy Table
Copy table object.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null |
param table: | table to copy |
---|
Create Table
Create Table object from data.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
data | None | ||
trim | False | ||
columns | None | ||
index | None |
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) |
param index: | names of rows (optional) |
Export Table
Convert table object to standard Python containers.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
with_index | False | ||
as_list | True |
param table: | table to convert to dict |
---|---|
param with_index: | |
include index in values | |
param as_list: | export data as list instead of dict |
Filter Empty Rows
Remove all rows from the table which have only None values.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null |
The filtering will be done in-place.
param table: | table to filter |
---|
Filter Table By Column
Remove all rows where the column values don't match the given condition.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
column | null | ||
operator | null | ||
value | null |
Remove all rows where the column values don't match the given 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 |
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 |
The filtering will be done in-place.
Examples:
*** Tasks ***
# 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}
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) |
Find Table Rows
Find a row in the table by a given column value.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
column | null | ||
value | null | ||
as_list | False |
param table: | Table to find from |
---|---|
param column: | name of column to search |
param value: | value to match for |
param as_list: | return list instead of dictionary |
Get Table Cell
Get a cell value from table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
row | null | ||
column | null |
param table: | table to read from |
---|---|
param row: | row of cell |
param column: | column of cell |
Get Table Column
Get all column values from table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
column | null | ||
as_list | False |
param table: | table to read |
---|---|
param column: | column to read |
param as_list: | return list instead of dictionary |
Get Table Dimensions
Return table dimensions, as (rows, columns).
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null |
param table: | table to inspect |
---|
Get Table Row
Get a single row from table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
index | null | ||
as_list | False |
param table: | table to read |
---|---|
param row: | row to read |
param as_list: | return list instead of dictionary |
Get Table Slice
Return a new Table from a subset of given Table rows.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
start | None | ||
end | None |
param table: | table to read from |
---|---|
param start: | start index (inclusive) |
param start: | end index (inclusive) |
Group Table By Column
Group table by `column` and return a list of grouped Tables.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
column | null |
Group table by column and return a list of grouped Tables.
param table: | table to use for grouping |
---|---|
param column: | column which is used as grouping criteria |
Merge Tables
Create a union of two tables and their contents.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
tables | null | ||
index | None |
param tables: | Tables to merge |
---|---|
param index: | Column name to use as index for merge |
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 |
*** Tasks ***
${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 |
---|---|---|---|
table | null | ||
column | None | ||
as_list | False |
param table: | table to modify |
---|---|
param column: | column to remove |
param as_list: | return list instead of dictionary |
Pop Table Row
Remove row from table and return it.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
index | None | ||
as_list | False |
param table: | table to modify |
---|---|
param index: | row index, pops first row if none given |
param as_list: | return list instead of dictionary |
Read Table From Csv
Read a CSV file as a table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | null | ||
header | None | ||
columns | None | ||
dialect | None | ||
delimiters | None | ||
column_unknown | Unknown | ||
encoding | None |
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 |
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.
Valid 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:
*** Tasks ***
# 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 be use previous value.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
columns | null | ||
strict | False |
Renames columns in the Table with given values. Columns with name as None will be use previous value.
param table: | table to modify |
---|---|
param columns: | list of new column names |
param strict: | if True, raises ValueError if column lengths do not match |
Set Column As Index
Set existing column as index for rows.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
column | None |
param table: | table to modify |
---|---|
param column: | column to convert to index |
Set Row As Column Names
Set existing row as names for columns.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
index | null |
param table: | table to modify |
---|---|
param index: | row to use as column names |
Set Table Cell
Set a cell value in the table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
row | null | ||
column | null | ||
value | null |
param table: | table to modify to |
---|---|
param row: | row of cell |
param column: | column of cell |
param value: | value to set |
Set Table Column
Assign values to entire column in the table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
column | null | ||
values | null |
param table: | table to modify |
---|---|
param column: | column to modify |
param values: | value(s) to set |
Set Table Row
Assign values to a row in the table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
row | null | ||
values | null |
param table: | table to modify |
---|---|
param row: | row to modify |
param values: | value(s) to set |
Sort Table By Column
Sort table in-place according to `column`.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
column | null | ||
ascending | False |
Sort table in-place according to column.
param table: | table to sort |
---|---|
param column: | column to sort with |
param ascending: | |
table sort order |
Table Head
Return first `count` rows from table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
count | 5 | ||
as_list | False |
Return first count rows from table.
param table: | table to read from |
---|---|
param count: | number of lines to read |
param as_list: | return list instead of Table |
Table Tail
Return last `count` rows from table.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
count | 5 | ||
as_list | False |
Return last count rows from table.
param table: | table to read from |
---|---|
param count: | number of lines to read |
param as_list: | return list instead of Table |
Trim Column Names
Remove all extraneous whitespace from column names.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null |
Trim Empty Rows
Remove all rows from the end of the table which have only None values.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null |
Remove all rows from the end of the table which have only None values.
param table: | table to filter |
---|
Write Table To Csv
Write a table as a CSV file.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
table | null | ||
path | null | ||
header | True | ||
dialect | excel | ||
encoding | None |
param path: | path to write to |
---|---|
param table: | table to write |
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 |
Valid dialect values are excel, excel-tab, and unix.