fredag 13. april 2018

Google Spreadsheet importDATA error.

I've been struggling with the IMPORTDATA function in Google Spreadsheet to import CSV data, everything seems to work normally the first time I load the file, but after a while I get NA and error in the spreadsheet, and of course the data is removed from the sheet.

I did read somwhere that the problem may be related to caching of data, I do not know if the problem is local cache or remote cache at google servers.

I found a solution which seems to work better than others, it may not work in your case but try it.

The normal way I add the IMPORTDATA formula is as follows:

=IMPORTDATA("http://www.data.com/testdata")
this fails, the solution I foudn was to add IFERROR and repeat the IMPORTDATA and adding trailing slashes to the URL. Trailing slashes does not seem to alter the url at all (may be a problem if you link directly to a CSV file, I'm using url_rewrite on my webserver), it seems to trick the cache problem. For now I'm using this formula with two nested IFERRORs:

=IFERROR(IMPORTDATA("http://www.data.com/testdata/");IFERROR(IMPORTDATA("http://www.data.com/testdata//");IMPORTDATA("http://www.data.com/testdata///"))) 

You can add more IFERRORS as well with even more trailing slashes.