Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!