Home > OS >  IMPORTDATA gets lots of errors because I am trying to load many cells for stock quotes
IMPORTDATA gets lots of errors because I am trying to load many cells for stock quotes

Time:09-27

I have a Google Sheet with 220 'importdata' functions where each one is pulling a stock quote off a website. The function is just a simple:

importdata("http://<URL>/"&A2)

where A2 contains the symbol like 'GOOG' and the <URL> is the website's URL.

With 220 of these importdata's, I get the error:

"Error Loading data may take a while because of the large number of requests. Try to
reduce the amount of IMPORTHTML, IMPORTDATA, IMPORTFEED or IMPORTXML functions across
spreadsheets you've created."

The errors never go away even if I wait a long time.

See picture showing just a small section of the sheet.

https://imgur.com/a/D7QnWYj

Is there any way to fix this? I would like to put in a random delay for each of these quotes from 1-5 seconds which would fix this problem but I don't know how.

CodePudding user response:

One option, you could implement your own importdata function which would not be limited by the errors above. It would look something similar to:

  var response = UrlFetchApp.fetch(url);
  var responseData = response.getBlob().getDataAsString();
  var data = Utilities.parseCsv(responseData, ',');
  return data;
}

and add it in Tools > Script Editor as described in https://www.roelpeters.be/solve-loading-data-may-take-a-while-when-using-importdata-in-google-spreadsheets/

or you could try either one of these https://github.com/search?q=CryptocurrencySpreadsheetUtils instead

They implement a custom function to load the price data in bulk instead of adding 100s of importdata function calls so that you won't have any issues around that.

  • Related