Converter (TSV to Excel-CSV)

A tab delimited text (TSV) stored in a String type data item is saved as an Excel compatible CSV file in a String type data item.

    A. Select STRING DATA for TSV DataData selectStringRequired
    B. Set COL IDs for Extraction (e.g. "0,1,5,3,6")Single-line inputRequired
    C. Select STRING DATA for File NameData selectString(single line)Required
    D. Select FILE DATA (update)Data selectFileRequired
    -variable namevariable label
    Aconf_DataIdASelect STRING DATA for TSV Data
    Bconf_ColIdsSet COL IDs for Extraction (e.g. "0,1,5,3,6")
    Cconf_DataIdCSelect STRING DATA for File Name
    Dconf_DataIdDSelect FILE DATA (update)
    // Converter from TSV to Excel-CSV (ver. 20161122)
    // (c) 2016, Questetra, Inc. (the MIT License)
    
    //// == 自動工程コンフィグの参照 / Config Retrieving ==
    var dataIdA = configs.get( "conf_DataIdA" );
    var colIds = configs.get( "conf_ColIds" ) + "";
    var dataIdC = configs.get( "conf_DataIdC" );
    var dataIdD = configs.get( "conf_DataIdD" );
    
    //// == ワークフローデータの参照 / Data Retrieving ==
    var sourceTsv = data.get( dataIdA ) + "";
    var fileName = data.get( dataIdC ) + "";
    
    //// == 演算 / Calculating ==
    var linesArray = sourceTsv.split("\n"); // string[]
    var colIdArray = colIds.split(",");
    var numOfCols = colIdArray.length;
    
    var myTsv = "";
    for (var i=0; i < linesArray.length; i++){
      var cellsArray = linesArray[i].split("\t"); // string[]
      for( var j = 0; j < numOfCols; j++ ){
        myTsv += cellsArray[ parseInt( colIdArray[j] ) ] + "";
        if( j != numOfCols - 1 ){
          myTsv += "\t";
        }
      }
      if( i != linesArray.length -1 ){
        myTsv += "\n";
      }
    }
    
    var csvFiles = new java.util.ArrayList();
    csvFiles.add(
      new com.questetra.bpms.core.event.scripttask.NewQfile(
        fileName,
        "text/tab-separated-values; charset=x-UTF-16LE-BOM", 
        myTsv
      )
    );
    
    //// == ワークフローデータへの代入 / Data Updating ==
    retVal.put( dataIdD, csvFiles );
    

    • A’: TSV text stored in the Data Item that is selected at config A
    • TSV text A’ will be stored as an Excel-compatible CSV file in the Data Item selected at config B
    • It is also capable of changing the order of columns, filtering, listing duplicately.
    • The file entity consists of tab-separated-values (utf-16le-bom)
    • The SJIS version consists of comma-separated-values.  The availability of smartphone display and data import will increase, but Comma information will be missing.