Linked Google Sheet: https://docs.google.com/spreadsheets/d/1j2P2V0SCiE7QtK7kdCorpLfYQPFRghKMw4tuCYbqce0/edit?usp=sharing
I have a form that outputs all products and qua
Here is some code that I've tested and it works. The code removes all the words "Product: ", and replaces them with a comma. Then the code does something similar with the string "Quantity: ", replacing it with an empty string. Next it creates an array, and converts the array to a two dimensional array, so that the rows and columns can be written all in one action.
function convertData() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName('Form Submission');
var data = sh.getRange("O2").getValue();
//Logger.log(data);
var firstProductRemoved = data.replace("Product: ", "");
//Logger.log(firstProductRemoved);
var allProductReplacedWithComma = firstProductRemoved.replace(/Product: /g,",");
//Logger.log(allProductReplacedWithComma);
var allQuantityReplacedWithNothing = allProductReplacedWithComma.replace(/Quantity: /g,"");
//Logger.log(allQuantityReplacedWithNothing);
var dataAsArray = allQuantityReplacedWithNothing.split(",");
var outerArray = [], innerArray = [];
var i=0;
for (i=0;i