I have a sheet with multiple rows connected by "";" and I want to expand the strings while preserving 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;
}
Expected Output: resulting in two columns
ID | Output |
---|---|
01 | a |
01 | bcdfh |
01 | 345 |
01 | xyw |
01 | ... |
02 | aqwx |