Remove Empty Values
Verb: removeEmpty
Removes unassigned elements from a data structure.
In the case of a data table, only the row that has no registered data is removed.
Syntax
removeEmpty --datastructure(List<Variant>)
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--datastructure | Data Structure | Required | List<Any>, Data Table | Data structure, which can be a list or data table, where elements are removed when they have no value assigned to them. |
Example
Example 1: The Remove Empty Values command removes all items with no assigned value from a list of numbers "[0.10, ,20, ,30.40]".
defVar --name numberList --type List --innertype Numeric
setVar --name "${numberList}" --value "[0,10, ,20, ,30,40]"
logMessage --message "Current list elements: ${numberList};\r\nNumber of elements in list: ${numberList.Count}" --type "Info"
removeEmpty --datastructure ${numberList}
logMessage --message "List elements after removal: ${numberList};\r\nNumber of elements in list after removal: ${numberList.Count}" --type "Info"
// Return on the console:
// Current list elements: [0.10,,20,,30.40];
// Number of elements in list: 7
// List elements after removal: [0,10,20,30,40];
// Number of elements in list after removal: 5
Example 2: In a data table with 3 rows registered, one of them has no assigned value. Using the Remove Empty Values command allows you to remove only this line.
defVar --name dataTable --type DataTable
defVar --name excelFile --type Excel
// The "excelOpen" and "excelGetTable" commands are used in this context to get the data table that will be handled by the "removeEmpty" command.
// Download the following file for the data table that will be the basis for the script demonstration.
excelOpen --file "fileExcel_removeEmptyValues.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders dataTable=value
//
logMessage --message "Current data from data table: \r\n${dataTable}\r\nNumber of rows in data table: ${dataTable.Rows}" --type "Info"
removeEmpty --datastructure ${dataTable}
logMessage --message "Table data after removal: ${dataTable}\r\nNumber of rows in data table after removal: ${dataTable.Rows}" --type "Info"
// Return the following output in the console:
// Current data from data table:
// Ana, 1745238956, SP
// , ,
// Mariana, 1712457856, SP
// Number of rows in data table: 3
//
// Table data after removal:
// Ana, 1745238956, SP
// Mariana, 1712457856, SP
// Number of rows in data table after removal: 2
For the correct operation of the script above, it is necessary to download the file and enter its path in the parameter File of the command Open Excel File.
Remarks
When the data structure is a data table, the removed elements are only the completely empty rows of the table.