Last active
October 31, 2022 16:19
-
-
Save varun-raj/5350595a730a62ca1954 to your computer and use it in GitHub Desktop.
Google App Script To Fetch Data From JSON Webservice and Write them to google spreadsheet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pullJSON() { | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheets = ss.getSheets(); | |
var sheet = ss.getActiveSheet(); | |
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here | |
var response = UrlFetchApp.fetch(url); // get feed | |
var dataAll = JSON.parse(response.getContentText()); // | |
var dataSet = dataAll; | |
var rows = [], | |
data; | |
for (i = 0; i < dataSet.length; i++) { | |
data = dataSet[i]; | |
rows.push([data.id, data.name,data.email]); //your JSON entities here | |
} | |
dataRange = sheet.getRange(1, 1, rows.length, 3); // 3 Denotes total number of entites | |
dataRange.setValues(rows); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great and useful - any tips on bringing in a lot of data? I've got ~50k lines of data w 8 data points and I get only very slow responses and timeouts. Thanks!