3

We have a Google Spreadsheet that pulls data from an external source via an IMPORTDATA() function and then a Google Apps Script that is on a timed trigger that performs other things with the imported data.

It's failed a few times which makes us wonder whether the IMPORTDATA() function is refreshing the data if the sheet is not manually opened? Or in other words when the Apps Script fires from it's timed trigger does the sheet automatically refresh it's formulas?

6

The IMPORTDATA() function has a latency of approximately 1 hour, as explained in this post on the Google Product Forum.

You mentioned the fact that a script was being fired by a time based Google Apps Script trigger. I was thinking, if you're using a script in the first place, why not fetch the CSV file as well, like so:

Code

var url = 'url to public CSV file';
var text = UrlFetchApp.fetch(url).getContentText();
var csv = Utilities.parseCsv(text);

The var csv is turned into a 2d-array and can be used like any other array. This way, you always have the latest CSV file.

References

  • Excellent idea, thanks for the quick response. – Jamonroad Mar 18 '14 at 13:42
  • @Jamonroad I am using following IMPORTDATA function =IMPORTDATA("google.com/finance/…) Can you pls help me how to write Script or a sample code in which I can replace the data I need. Thanks. – neo269 Mar 12 '18 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.