空の値の削除
verb: removeEmpty
未割り当てエレメントをデータ構造から削除します。
データ表の場合、登録されたデータが入っていない行のみが削除されます。
構文
removeEmpty --datastructure(List<Variant>)
入力
| スクリプト | Designer | 必須 | AcceptedTypes | 説明 |
|---|---|---|---|---|
| --datastructure | データ構造 | 必須 | リスト<Any>、データ表 | データ構造 (リストまたはデータ表のいずれか)。その中で値が割り当てられていないエレメントが削除されます。 |
例
例 1: 空の値の削除 コマンドで、値が割り当てられていないすべての項目が数値のリスト「[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
例 2: 3 つの行が登録されているデータ表の 1 つの行に値が割り当てられていません。 空の値の削除 コマンドを使用すると、その行だけを削除できます。
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
上記のスクリプトを正しく操作するには、ファイルをダウンロードし、「Excel ファイルを開く」コマンドの「ファイル」パラメーターにそのパスを入力する必要があります。
注釈
データ構造がデータ表の場合、削除されるエレメントは、表の完全に空の行だけとなります。