I'm trying to grab the data for my spreadsheet for the rows and headers based on a unique identifier. I can grab the data easily enough, put it into an array, but I cannot figure out how to transpose the data into a column. tried to sanitize so forgive if i missed something.
test sheet:
https://docs.google.com/spreadsheets/d/195YJwCj5KUljVnIldooQ-1DMEvw1b4vPj6-9Hc1xgJA/edit?usp=sharing
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var uid = "2" //will eventually be dynamic, testing
var allData = sheet.getDataRange().getValues();
var temp = [];
var dataTemp = []
var uidList = allData.getRange(1, 2, allData.getLastRow(), 1).getValues().map(function (r) { return r[0] })
var uidIndex = uidList.indexOf(uid)
var rowData = []
var headers = []
allData[0].forEach(function (r) { headers.push(r) })
allData[0].forEach(function (x, i) {
rowData.push(allData[uidIndex][i])
})
var combined = []
combined.push(headers)
combined.push(rowData)
combined[0].forEach((x, i) => { //grab headers
temp.push(combined[i][0])
});
combined[1].forEach((x, i) => { //grab data row
dataTemp.push(combined[i][1])
});
// sheet.getRange(3,1,combined[0].length,combined.length).setValues(temp)
}