Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
GAS: how can I make this script faster?

The sheet has multiple rows joined by ";" and I need to expand the strings and also keep the table IDs.

ID Column X: Joined Rows
01 a;bcdfh;345;xyw...
02 aqwx;tyuio;345;xyw...
03 wxcv;gth;2364;x89...
function expand_joins(range) {
  var output2 = [];
  for(var i = 0, iLen = range.length; i < iLen; i++) {
    var s = range[i][1].split(";");    
    for(var j = 0, jLen = s.length; j < jLen; j++) {
      var output1 = []; 
      for(var k = 0, kLen = range[0].length; k < kLen; k++) {
        if(k == 1) {
          output1.push(s[j]);
        } else {
          output1.push(range[i][k]);
        }
      }
      output2.push(output1);
    }    
  }
  return output2;
}

Desirable Output: two columns

ID Output
01 a
01 bcdfh
01 345
01 xyw
01 ...
02 aqwx
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

UPDATED

If you're using the V8 runtime (new IDE) you can try the following:


function expandJoins(range) {
    return range
        .map(row => row[1]
            .split(';')
            .map(splitItem => [row[0], splitItem])
        )
        .flat();
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda