Google sheets app script - taking horizontal data and setting it vertically
I'm trying to take a sequence of data that's arranged horizontally in a single row from the google sheets app using the google script function getValues, and then put them into a different sheet arranged vertically in a single column. My code currently looks like this:
function tester() {
var app = SpreadsheetApp;
var loader = app.getActiveSpreadsheet().getSheetByName('Loader');
var stats = app.getActiveSpreadsheet().getSheetByName('Stats');
var list = app.getActiveSpreadsheet().getSheetByName('List');
var xpos = 19;
var ypos = 2;
var abilityBlock = list.getRange(ypos,xpos,1,16).getValues();
Logger.log(abilityBlock);
//loader.getRange(10,5,16,1).setValues(abilityBlock);
}
I have the setValues portion commented out because it returns an error, saying it expected the data to be 16 wide, when the data it's grabbing is 16 tall.
From what I'm able to gather the culprit here is how the data is getting pulled into the array. The Logger displays the data as [[value1,value2,value3,value4,etc..]] instead of [[value1],[value2],[value3],[value4],[etc...]]
I'd like to avoid using a for loop to push the data in one at a time, is there another way to convert the data in the array? Or another way to use the getValues operation to grab it in a format I can actually use it?
google-apps-script google-sheets
add a comment |
I'm trying to take a sequence of data that's arranged horizontally in a single row from the google sheets app using the google script function getValues, and then put them into a different sheet arranged vertically in a single column. My code currently looks like this:
function tester() {
var app = SpreadsheetApp;
var loader = app.getActiveSpreadsheet().getSheetByName('Loader');
var stats = app.getActiveSpreadsheet().getSheetByName('Stats');
var list = app.getActiveSpreadsheet().getSheetByName('List');
var xpos = 19;
var ypos = 2;
var abilityBlock = list.getRange(ypos,xpos,1,16).getValues();
Logger.log(abilityBlock);
//loader.getRange(10,5,16,1).setValues(abilityBlock);
}
I have the setValues portion commented out because it returns an error, saying it expected the data to be 16 wide, when the data it's grabbing is 16 tall.
From what I'm able to gather the culprit here is how the data is getting pulled into the array. The Logger displays the data as [[value1,value2,value3,value4,etc..]] instead of [[value1],[value2],[value3],[value4],[etc...]]
I'd like to avoid using a for loop to push the data in one at a time, is there another way to convert the data in the array? Or another way to use the getValues operation to grab it in a format I can actually use it?
google-apps-script google-sheets
add a comment |
I'm trying to take a sequence of data that's arranged horizontally in a single row from the google sheets app using the google script function getValues, and then put them into a different sheet arranged vertically in a single column. My code currently looks like this:
function tester() {
var app = SpreadsheetApp;
var loader = app.getActiveSpreadsheet().getSheetByName('Loader');
var stats = app.getActiveSpreadsheet().getSheetByName('Stats');
var list = app.getActiveSpreadsheet().getSheetByName('List');
var xpos = 19;
var ypos = 2;
var abilityBlock = list.getRange(ypos,xpos,1,16).getValues();
Logger.log(abilityBlock);
//loader.getRange(10,5,16,1).setValues(abilityBlock);
}
I have the setValues portion commented out because it returns an error, saying it expected the data to be 16 wide, when the data it's grabbing is 16 tall.
From what I'm able to gather the culprit here is how the data is getting pulled into the array. The Logger displays the data as [[value1,value2,value3,value4,etc..]] instead of [[value1],[value2],[value3],[value4],[etc...]]
I'd like to avoid using a for loop to push the data in one at a time, is there another way to convert the data in the array? Or another way to use the getValues operation to grab it in a format I can actually use it?
google-apps-script google-sheets
I'm trying to take a sequence of data that's arranged horizontally in a single row from the google sheets app using the google script function getValues, and then put them into a different sheet arranged vertically in a single column. My code currently looks like this:
function tester() {
var app = SpreadsheetApp;
var loader = app.getActiveSpreadsheet().getSheetByName('Loader');
var stats = app.getActiveSpreadsheet().getSheetByName('Stats');
var list = app.getActiveSpreadsheet().getSheetByName('List');
var xpos = 19;
var ypos = 2;
var abilityBlock = list.getRange(ypos,xpos,1,16).getValues();
Logger.log(abilityBlock);
//loader.getRange(10,5,16,1).setValues(abilityBlock);
}
I have the setValues portion commented out because it returns an error, saying it expected the data to be 16 wide, when the data it's grabbing is 16 tall.
From what I'm able to gather the culprit here is how the data is getting pulled into the array. The Logger displays the data as [[value1,value2,value3,value4,etc..]] instead of [[value1],[value2],[value3],[value4],[etc...]]
I'd like to avoid using a for loop to push the data in one at a time, is there another way to convert the data in the array? Or another way to use the getValues operation to grab it in a format I can actually use it?
google-apps-script google-sheets
google-apps-script google-sheets
edited Nov 15 '18 at 15:58
TheMaster
10.2k3835
10.2k3835
asked Nov 14 '18 at 15:05
Tim BTim B
31
31
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I think you want to use the transpose functionality.
try this
list.getRange(ypos,xpos,1,16).copyTo(loader.getRange(10,5),
spreadsheetApp.CopyPasteType.PASTE_VALUES, true);
description here : https://developers.google.com/apps-script/reference/spreadsheet/range#copyTo(Range,CopyPasteType,Boolean)
Thanks. I had to finangle this a tiny bit, but it worked otherwise. For some reason my sheet didn't like using 'spreadsheetApp' when defining the parameters of the CopyPasteType, but I used the prior defined app variable and it worked like a charm.
– Tim B
Nov 14 '18 at 15:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303214%2fgoogle-sheets-app-script-taking-horizontal-data-and-setting-it-vertically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you want to use the transpose functionality.
try this
list.getRange(ypos,xpos,1,16).copyTo(loader.getRange(10,5),
spreadsheetApp.CopyPasteType.PASTE_VALUES, true);
description here : https://developers.google.com/apps-script/reference/spreadsheet/range#copyTo(Range,CopyPasteType,Boolean)
Thanks. I had to finangle this a tiny bit, but it worked otherwise. For some reason my sheet didn't like using 'spreadsheetApp' when defining the parameters of the CopyPasteType, but I used the prior defined app variable and it worked like a charm.
– Tim B
Nov 14 '18 at 15:50
add a comment |
I think you want to use the transpose functionality.
try this
list.getRange(ypos,xpos,1,16).copyTo(loader.getRange(10,5),
spreadsheetApp.CopyPasteType.PASTE_VALUES, true);
description here : https://developers.google.com/apps-script/reference/spreadsheet/range#copyTo(Range,CopyPasteType,Boolean)
Thanks. I had to finangle this a tiny bit, but it worked otherwise. For some reason my sheet didn't like using 'spreadsheetApp' when defining the parameters of the CopyPasteType, but I used the prior defined app variable and it worked like a charm.
– Tim B
Nov 14 '18 at 15:50
add a comment |
I think you want to use the transpose functionality.
try this
list.getRange(ypos,xpos,1,16).copyTo(loader.getRange(10,5),
spreadsheetApp.CopyPasteType.PASTE_VALUES, true);
description here : https://developers.google.com/apps-script/reference/spreadsheet/range#copyTo(Range,CopyPasteType,Boolean)
I think you want to use the transpose functionality.
try this
list.getRange(ypos,xpos,1,16).copyTo(loader.getRange(10,5),
spreadsheetApp.CopyPasteType.PASTE_VALUES, true);
description here : https://developers.google.com/apps-script/reference/spreadsheet/range#copyTo(Range,CopyPasteType,Boolean)
answered Nov 14 '18 at 15:32
corn3liuscorn3lius
3,60512030
3,60512030
Thanks. I had to finangle this a tiny bit, but it worked otherwise. For some reason my sheet didn't like using 'spreadsheetApp' when defining the parameters of the CopyPasteType, but I used the prior defined app variable and it worked like a charm.
– Tim B
Nov 14 '18 at 15:50
add a comment |
Thanks. I had to finangle this a tiny bit, but it worked otherwise. For some reason my sheet didn't like using 'spreadsheetApp' when defining the parameters of the CopyPasteType, but I used the prior defined app variable and it worked like a charm.
– Tim B
Nov 14 '18 at 15:50
Thanks. I had to finangle this a tiny bit, but it worked otherwise. For some reason my sheet didn't like using 'spreadsheetApp' when defining the parameters of the CopyPasteType, but I used the prior defined app variable and it worked like a charm.
– Tim B
Nov 14 '18 at 15:50
Thanks. I had to finangle this a tiny bit, but it worked otherwise. For some reason my sheet didn't like using 'spreadsheetApp' when defining the parameters of the CopyPasteType, but I used the prior defined app variable and it worked like a charm.
– Tim B
Nov 14 '18 at 15:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303214%2fgoogle-sheets-app-script-taking-horizontal-data-and-setting-it-vertically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown