I have a two dimensional array with one row and many columns. I would like to flip this into a two dimensional array variable with one column and many rows.
var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(market);
var shrinkLog = SpreadsheetApp.openById("1h3B4HN4mEnBvlx-8aNa9_2ooEZrkY_qLuJcuJXZq7dM").getSheetByName(market);
var dataArr = shrinkLog.getRange(2,3,1,shrinkLog.getLastColumn()).getValues();
I think the answer is in the map function, but keep returning errors, or getting different versions of the same one dimensional array. help is much appreciated.
I guess your goal as follows.
var dataArr = shrinkLog.getRange(2,3,1,shrinkLog.getLastColumn()).getValues()
, you want to retrieve the result from [[data1, data2, data3,,,]]
to [[data1], [data2], [data3],,,]]
. In your case, shrinkLog.getRange(2,3,1,shrinkLog.getLastColumn()).getValues()
returns [[data1, data2, data3,,,]]
. So when your goal is achieved with map
, the modified script is as follows.
var dataArr = shrinkLog.getRange(2,3,1,shrinkLog.getLastColumn()).getValues()[0].map(c => [c]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.