Multiline String; Delete Header Lines
Deletes the header lines of a multiline string, like CSV text or TSV text. Note that blank characters at the end or beginning of string data are deleted in advance. If singleline text, an empty string will be returned.
Configs
  • A: Select STRING DATA for Multiline Text *
  • B: Set Number of Header Lines to Delete (e.g. “1”) *
  • C: Select STRING DATA for Header-Deleted Text (update) *
Script (click to open)
// GraalJS Script (engine type: 2)
// (c) 2021, Questetra, Inc. (the MIT License)

//////// START "main()" ////////
main();
function main(){ 


//// == Config Retrieving / 工程コンフィグの参照 ==
const dataIdA = configs.get( "conf_DataIdA" ) + ""; // config required
const delNum  = configs.get( "conf_DelNum" )  + ""; // config required
const dataIdC = configs.get( "conf_DataIdC" ) + ""; // config required
const intDelNum  = parseInt( delNum );
// Design-time Config Format Check
if ( isNaN( intDelNum )){
  throw new Error( "\n AutomatedTask UnexpectedConfigError:" +
                   " Config DelNum is not an integer \n" );
}


//// == Data Retrieving / ワークフローデータの参照 ==
// Run-time Data Format Check
if( engine.findDataByNumber( dataIdA ) === null ){
  throw new Error( "\n AutomatedTask UnexpectedStringError:" +
                   " String {A} is null \n" );
}
const inputText = (engine.findDataByNumber( dataIdA ) + "").trim();
if( inputText === "" ){
  throw new Error( "\n AutomatedTask UnexpectedStringError:" +
                   " String {A} is empty \n" );
}


//// == Calculating / 演算 ==
let   outputText = "";
const arrInputText = inputText.split("\n");
engine.log( " AutomatedTask MultilineString:" + 
            " String {A}, number of lines " + arrInputText.length );
if( arrInputText.length < intDelNum ){
  engine.log( " AutomatedTask StringWarning:" +
    " String {A}, number of lines is smaller than DelNum \n" );
}else{
  for (let i = intDelNum; i < arrInputText.length; i++){
    outputText += arrInputText[i];
    if( i !== arrInputText.length - 1 ){
      outputText += "\n";
    }
  }
}


//// == Data Updating / ワークフローデータへの代入 ==
engine.setDataByNumber( dataIdC, outputText );


} //////// END "main()" ////////

Download

2021-07-13 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/multiline-string-delete-header-lines-2021/
The Add-on import feature is available with Professional or Enterprise edition.

Capture

See also

2 thoughts on “Multiline String; Delete Header Lines”

  1. Pingback: Multiline String; Delete Header Lines – Questetra Support

  2. Pingback: Multiline String; Delete Footer Lines – Questetra Support

Comments are closed.

%d bloggers like this: