Answer the question
In order to leave comments, you need to log in
What is the best way to upload a list of cities received from Nova Poshta to a Google spreadsheet?
Hello.
What is the best way to upload a list of cities received from Nova Poshta to a Google spreadsheet? This list contains 4550 items.
In the answer that comes from Nova Poshta, the list is divided into 100 items. It is better to unload in one column or in 46 columns. By default, there are only 1000 lines per page. Who has already worked with this list. Tell me how best to unload for further work with this list? And at the same time, the code that can be used to upload this list. Thanks in advance to everyone who helps.
Program code for getting a list of cities from Nova Poshta
function getCities () {
const formData = {
// Ваш ключ API 2.0
"apiKey": '********************************************',
"modelName": "Address",
"calledMethod": "getCities"
};
const options = {
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"payload": JSON.stringify(formData)
};
const url = "https://api.novaposhta.ua/v2.0/json/";
const response = UrlFetchApp.fetch(url, options);
var orderList = JSON.parse(response.getContentText());
var orderList = JSON.stringify(orderList, null, 2);
//Logger.log(orderList);
Answer the question
In order to leave comments, you need to log in
There are 5M cells in the Table. Upload as you like.
Main idea:
/**
*
* @param {GoogleAppsScript.Spreadsheet.Sheet} sheet
* @param {Array.<Array.<string>>} data
* @return {GoogleAppsScript.Spreadsheet.Range}
*/
function appendData(sheet, data) {
const lastRow = sheet.getLastRow() + 1;
return sheet
.getRange(lastRow, 1, lastRow + data.length, data[0].length)
.setValues(data);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question