Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get data from Redash and write to spreadsheet by Google App Script
function getDataFromRedash() {
var ss = SpreadsheetApp.openById('XXXXXXXXXX');
var sh = ss.getSheetByName('input profile 1');
// Refresh data (User API Key)
UrlFetchApp.fetch("https://XXX.XXX.XXX/api/queries/XXX/refresh?api_key=XXXXXXXXXX", {"method": "post"});
// Get CSV data (Query API Key)
var url = "https://XXX.XXX.XXX/api/queries/XXX/results.csv?api_key=XXXXXXXXXX";
var response = UrlFetchApp.fetch(url);
var csv = Utilities.parseCsv(response.getContentText("UTF-8"));
// Add date
var today = Utilities.formatDate(new Date(), "JST", "yyyy/MM/dd");
var data = csv[1].concat()
// Write to spreadsheet
sh.getRange(sh.getLastRow() + 1,1,1,data.length).setValues([data]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.