Reputation: 91
First, I'd like to apologize in advance because I think (hope?) this is an easy answer but I've been searching and testing without a successful result.
I have a column of data in a Google Sheet, with each cell value containing an independent value:
Column A
abc
def
etc.
I have function that sends this data to another place for crunching, but first I need to add quotation marks around each cell value like so:
Column A
"abc"
"123"
"etc."
Currently I'm doing this via a concatenate in a helper column, but I'd like to do this directly within the Script. Right now all my attempts have resulted in this output in the logger:
"abc, 123, etc."
Rather than the intended result of "abc","123","etc.".
Thanks in advance!
Upvotes: 0
Views: 50
Reputation: 666
value = '"' + value + '"';
should do the trick.
Or, if you're getting your values via getValues
function:
var values = ss.getRange('A1:A3').getValues();
for (var i = 0; i < values.length; i++) {
for (var j = 0; j < values[0].length; j++) {
values[i][j] = '"' + values[i][j] + '"';
}
}
Logger.log(values);
ss.getRange('A1:A3').setValues(values);
Upvotes: 1