I'm looking for some help on looping through a set of data in a spreadsheet by row, then write the value in the first cell to a new sheet followed by each cell value across the rows.
Here is a link to a sample set of data. Sample Data
Sheet1 on the above spreadsheet shows the raw data. I want to read in that data and write it to sheet two (2) so that it looks like what is on sheet 2 of the above link.
Here is the current code I have but it writes all data into a single column.
function myfunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var sheet2 =
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');
var data = sheet.getDataRange().getValues();
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].length; j++) {
var iava_value = (data[i][0]);
var lastRow = sheet2.getLastRow();
sheet2.getRange(lastRow +1, +1).setValue(data[i][j]);
}
}
}