Removes all blank rows. Line breaks at the end of the text (including TSV and CSV) are also removed. If there is even one single-byte space on the line, it will not be deleted.
Configs
A1: Set Original Text *#{EL}
B1: Select STRING DATA that stores Output Text (update) *
Script (click to open)
// GraalJS Script (engine type: 2)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const strInput = configs.get( "StrConfA1" ); /// REQUIRED //////////////
if( strInput === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {A1: Text} is empty \n" );
}
const strPocketOutput = configs.getObject( "SelectConfB1" ); /// REQUIRED //////////////
//// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)
//// == Calculating / 演算 ==
const arrInput = strInput.split("\n");
engine.log( " AutomatedTask: Number of Lines: " + arrInput.length );
let strOutput = "";
for( let i = 0; i < arrInput.length; i++ ){
if( arrInput[i] === "" ){
engine.log( " AutomatedTask Deleted LineId: " + i );
continue;
} // Skip blank lines
strOutput += arrInput[i] + "\n";
}
strOutput = strOutput.slice( 0, -1 ); // delete last "\n"
//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( strPocketOutput, strOutput );
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- When the process reaches this automated task, the Text in the string data is automatically processed.
- TSV data, Access log, Email body, etc.
- {Number of lines} = {Number of line breaks} + 1
- All blank lines in the text are automatically removed.
- Not only the blank line in the middle of the multiline string,
- but also the blank line at the end and the blank line at the beginning are deleted.
APPENDIX:
- The deleted row ID (starting with zero) is logged.
Notes-ja:
- 案件が自動処理工程に到達した際、文字列型データに保存されているTextが自動的に加工されます。
- TSVデータ、アクセスログ、メール本文など
- {行の数} = {改行の数} + 1
- テキスト内の全ての空行が自動的に取り除かれます。
- 複数行文字列にある途中空行のみならず、末尾空行や先頭空行も削除されます。
APPENDIX-ja:
- 削除された行のID(ゼロ始まり)はログ出力されます。
*/
Pingback: Multiline String; Delete Footer Lines – Questetra Support
Pingback: Multiline String; Delete Header Lines – Questetra Support
Pingback: Singleline String, Set One Line from Multiline using Round-Robin – Questetra Support