Monday, January 18, 2016

yogi_Split Entries In Sheet 'yC' With Collection Column F Delimited By Specified Character Into DataBase Layout

Google Spreadsheet   Post  #2024
Yogi Anand, D.Eng, P.E.      ANAND Enterprises LLC -- Rochester Hills MI   Jan-18-2016
post by: Training Development Changi Airport:!topic/docs/NL7QojMMoYs;context-place=forum/docs
How to generate new rows from multiple comma-separated values in a single column
Hi, I do not have any programming background in JavaScript but have been attempting to do the Apps Script to write codes based on what I read online.

Basically I need to do exactly what he did in his article, and I have my spreadsheet here 

In the tab Form Responses 2, I have a Google form linked to it whereby people can enter multiple names by separating them with commas. I need to generate new rows from each name, and have the other columns and their contents duplicated into the corresponding rows. However when I try to use the below code, I am still unable to obtain the new rows with each name.

Is anyone kind enough to assist?

function splitColumnAndRepeatRows(anArray, splitColumnIndex) {
  var output = [];
  for (var i = 0; i < anArray.length; i++) { // for each row
    var splitArray = anArray[i][splitColumnIndex].toString().split("\n"); // split values in specified column
    for (var j = 0; j < splitArray.length; j++) { // for each split cell value
      if (splitArray[j] == "" && j >= 1)
      var row = anArray[i].slice(0); // take a copy of source row
      row[splitColumnIndex] = splitArray[j];
      output.push(row); // push new row to output
  return output;