I'm working on a project that outputs a huge array, and I need to clean it up to send in an email. It seems the simplest approach is the split() function, but I can't seem to make it work.
function splitArray() {
var ss = SpreadsheetApp.getActiveSheet();
var row = ss.getLastRow();
var range = ss.getRange(row, 1, 1, ss.getMaxColumns());
var data = range.getValues();
data.split("\n");
Logger.log(data);}
asked Sep 18, 2013 at 15:42
joshlsullivan
1,5302 gold badges16 silver badges21 bronze badges
1 Answer 1
You need to set the return value of data.split("\n"); to something.
You are splitting the value successfully but not storing that value anywhwere
Try:
data = data.split("\n");
or
Logger.log(data.split("\n"));
answered Sep 18, 2013 at 15:43
Andrew Hall
3,08323 silver badges30 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
joshlsullivan
This looks great, except that Google returns this: "TypeError: Cannot find function split in object". I'm not sure Google Apps Script recognizes the split function.
Andrew Hall
Seems like data is already an array. Try logging data before doing the split
Explore related questions
See similar questions with these tags.
lang-js