There is a google sheet coordinate set. It has a lot of coordinate values inside a single cell. As in the picture below. Here coordinate as N, E, Z. Here after the first coordinate 1 we have gone to the next line inside the same cell. I tried to separate the ones I wanted for one cell but it didn't work.
function sepCoordi() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Coordi");
//get data to array
var coor = sheet.getRange("A2:B47").getValues();
var one = coor[0][1];
Logger.log(one);
var onesplit = one.split(" ");
Logger.log(onesplit);
}
Result
This is how I want it [[80.091821,6.842871,98.23][80.091861,6.842881,106.1][80.091905,6.842894,109.25][....][....]]
CodePudding user response:
In your script and your showing Spreadsheet, how about the following modification?
Modified script:
function sepCoordi() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Coordi");
var coor = sheet.getRange("A2:B47").getValues();
// I modified below script.
var values = coor.flatMap(([,b]) => b.split("\n").map(e => e.split(",").map(f => f.trim())));
console.log(values)
}