コンバータ: テーブル to TSV文字列
コンバータ: テーブル to TSV文字列 (Converter: Table to TSV-String)
テーブル型データをTSV文字列に変換します。テーブル型データ項目内の全てのセルの文字列値がTSV文字列Bに上書きコピーされます。入力のないセルは空文字列とみなされます。
Configs
  • A: テーブル型データを選択してください *
  • B: TSV文字列が格納される文字列型データを選択してください(更新)
  • B2: TSV文字列が格納される文字列型データを選択してください(追記)
Script (click to open)

// GraalJS Script (engine type: 2)
// 
// Notes:
// Copies text information of all cell values.
// Copies in the display order of the column. (Does not depend on column ID)
// The value of Select-column is the option id. (Choice ID; not the displayed Label)
// To add data without erasing already stored cell data, use B2.
//
// Notes (ja):
// 全てのセル値の文字情報をコピーします。
// カラムの表示順にコピーします。(カラムIDに依らない)
// 選択カラムは、選択肢IDが出力されます。(表示テキストではありません)
// 既に格納されているセルデータを消さずに追記したい場合は、B2をご利用ください。


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

//// == Config Retrieving / 工程コンフィグの参照 ==
const dataIdA  = configs.get( "conf_DataIdA" )  + ""; // required
const dataIdB  = configs.get( "conf_DataIdB" )  + ""; // not required
const dataIdB2 = configs.get( "conf_DataIdB2" ) + ""; // not required
// 'java.lang.String' to javascript primitive 'string'

let numColsA  = 0;
numColsA  = engine.findDataDefinitionByNumber( dataIdA )
                  .getSubDataDefinitions().size() - 0;
// com.questetra.bpms.core.event.scripttask.ProcessDataDefinitionView
engine.log( " AutomatedTask TableConfig:" +
            " #of {A}-Columns Definition: " + numColsA );


//// == Data Retrieving / ワークフローデータの参照 ==
const inputTable = engine.findDataByNumber( dataIdA ); 
// com.questetra.bpms.core.event.scripttask.ScriptListArray (BPMS Table)
// https://questetra.zendesk.com/hc/en-us/articles/360024574471-R2300
if( inputTable === null ){
  throw new Error( "\n AutomatedTask UnexpectedTableError:" + 
                   " Table {A} is empty \n" );
}


//// == Calculating / 演算 ==
let outputTsv1 = "";
if( dataIdB !== "" ){
  for( let i = 0; i < inputTable.size() - 0; i++ ){
    for( let j = 0; j < numColsA; j++ ){
      outputTsv1 += inputTable.getRow(i).getCol(j) + "";
      if( j !== numColsA - 1 ){
        outputTsv1 += "\t";
      }
    }
    if( i !== inputTable.size() - 1 ){
      outputTsv1 += "\n";
    }
  }
}

let outputTsv2 = "";
if( dataIdB2 !== "" ){
  if( engine.findDataByNumber( dataIdB2 ) !== null ){
    outputTsv2 = engine.findDataByNumber( dataIdB2 ) + "\n";
  }
  for( let i = 0; i < inputTable.size() - 0; i++ ){
    for( let j = 0; j < numColsA; j++ ){
      outputTsv2 += inputTable.getRow(i).getCol(j) + "";
      if( j !== numColsA - 1 ){
        outputTsv2 += "\t";
      }
    }
    if( i !== inputTable.size() - 1 ){
      outputTsv2 += "\n";
    }
  }
}


//// == Data Updating / ワークフローデータへの代入 ==
if( dataIdB !== "" ){
  engine.setDataByNumber( dataIdB, outputTsv1 );
}
if( dataIdB2 !== "" ){
  engine.setDataByNumber( dataIdB2, outputTsv2 );
}

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

Download

2021-07-30 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/ja/addons/converter-table-to-tsv-string-2021/
Addonファイルのインポートは Professional でのみご利用いただけます

Notes

  1. 全てのセル値の文字情報をコピーします。
  2. カラムの表示順にコピーします。(カラムIDに依らない)
  3. 選択カラムは、選択肢IDが出力されます。(表示テキストではありません)
  4. 既に格納されているセルデータを消さずに追記したい場合は、B2をご利用ください。

Capture

See also

%d人のブロガーが「いいね」をつけました。