I have a spreadsheet that imports from various websites 10 tables using importhtml. I have a refresh script which helps me to update that data every 30 minutes. This is working fine. My problem is that plenty of times one or more of the importhtml fails which has as result all the cells that are using the data i am importing to give wrong results. Is there any way to keep the data I had taken earlier from importhtml if there is an error at refreshing?
maybe not what you need, but try to wrap your imports into 1-2 IFERRORs like:
=IFERROR(IMPORTHTML(...); IMPORTHTML(...))
or:
=IFERROR(IFERROR(IMPORTHTML(...); IMPORTHTML(...)); IMPORTHTML(...))
this way if some importing error occurs the IFERROR will re-try it. it may help in some cases - ofc not always.
Related
Been using getFileById & insertImage in a sheet/program for months with no problem but it suddenly stopped working two days ago. In order to solve the issue I created a fresh sheet and did this simple code:
function myFunction() {
var picId = "1x2jkgSQvVKAIOg6DQ0rss82YhTQl918c";
var picToPlace = DriveApp.getFileById(picId);
SpreadsheetApp.getActiveSpreadsheet().insertImage(picToPlace,1,1);
}
It works just like it should however if I stick the same code into my main sheet I get "Exception: The image could not be inserted. Please verify it is valid and try again."
Why is this happening? I'm not doing anything different, the function is sitting by itself. Been building this sheet/program for months. Have I overloaded the sheet somehow? Again, if I make a fresh, plain sheet, stick this code in it, it works fine, but if I go back to my main sheet, stick in the same function, it just refuses to work. Its in its own function, nothing else is happening w/in it, it's the only thing I'm calling. I'm at a lost trying to figure out why insertImage has completely stopped working in this sheet. There are thousands and thousands lines of code, over 15K rows of data in some tabs, it's referencing hundreds and hundreds of pictures I've uploaded to a server, and processing various aspects of thousands of people I've inputted into this program. Did I overload this sheet somehow or is Google just over me right now (ie, does it not like me trying to use insertImage, for example, 100 times in one call..) Sorry, I've put so much effort into this and the "insertImage" function suddenly not working is a major blow to it when it is NOT the code that is malfunctioning. If it was the code at least I could fix it.
What's odd is I was running the program 2 days ago. Would look up, for example, 100 people and then have it show me all the pics on one page. Ran this a few times and in the middle one of the outputs it suddenly stopped working. I re-ran a query, asked it to show me pictures and it started placing like 20 of them and then just refused to show any more at all. This really seems like Google telling me to f8ck off.
Update: It worked for 5 minutes then stopped working again. Not exactly sure why it's only working part of the time?
This sounds like it's supposed to be simple but I'm only finding information on "getActive" and my function works if I'm using all internal sheets but I tried using openById and nothing happened and openByUrl returns an error. The following is a simplified example of what I'm trying to do:
var store_data_sheet = SpreadsheetApp.openByID('ID here..').getSheetByName('Data');
store_data_sheet.getRange('A1').setValue('testing')
store_data_sheet.insertRows(1);
I'm sure I'm just using the wrong keywords or maybe this isn't even allowed but multiple users will be using their own copy of a specific sheet that runs this function and I'd just like to take certain cell's data and copy it to one external sheet (which is why it also inserts a row so it can push down entries)
Maybe I'm using the wrong "ID"? I assumed the number inside the URL was the ID. If it's something more specific, please let me know.
Like I said, this works flawlessly if I'm referencing an internal sheet. I'd like to be able to do the same exact thing with an external spreadsheet if possible. Thank you!
I found the issue. This function also renames the sheet file so if there is anything in the cell that is used to rename the file, it won't run the storing functions. I either need to run these before the renaming or take out the renaming aspect. ---moving these before the renaming part fixed the problem.
I have a short 1 line script to generate a random integer so I can set it up to run with a trigger so that every time an integer is generated my other scripts using it as a reference will update instead of using a cached version.
The problem is it seems to be running by itself without triggers about once every 10 minutes or so and I don't know what is causing it.
This is the code:
function RandomInt()
{
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Player List").getRange('B1').setValue(Math.random());
}
It works perfectly except the part about it running by itself.
Edit:
So far I believe I have found out that triggers are per user (I did not know this and couldn't find anything about it, but it might just be common sense) So someone else may have a trigger set up for it because a decent amount of people use the sheet.
I ran the deleteTriggers() script Craig posted at Unable to delete triggers (google-apps-script)
And have not noticed the script running by itself anymore. The value has been the same for the last 30 minutes instead of changing every 10.
Edit2: It seems it was alright at first it stopped updating itself but when I added a trigger to update once per hour it started updating it randomly at approximately every 10 minute intervals again.
Edit3: I have abandoned trying to figure out what is wrong and decided to do
function Update()
{
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Player List").getRange('B1').setValue(new Date().getUTCHours());
}
This instead it works well with triggers and even if you set it to shorter intervals it doesn't change the value until the next hour.
Edit4: I have confirmed that the problem was created by someone elses triggers running to every 10 minutes, so the script should work fine, not sure how to close this.
I'm trying to transfer a ton of data from an old sharepoint platform through access to sharepoint 365.
When I do this, I get an error like this:
Picture of access
As far as I can tell, this means that theres either a server problem, or something was misspelled.
I can transfer several other views without any problems, so im hoping that someone out there can shed some light on this.
Cause of this problem can be in names of attachments. Just now I had the same problem importing the SP2007 list to Access and I find out, that I can import everything except two records with attachment, which name contained + symbol. I had to delete the attachment, then the import was OK.
Bigger problem was to find problematic records - I had to make special view filtered by date of last change and then tryied importing records from different time scopes, until I identified records causing the trouble.
I hope you can help me. I have been trying to get this working for quite some time.
I am taking the API from a website import it into google spreadsheets VIA importjson()
ImportJSON("http://api.796.com/v3/futures/ticker.html?type=weekly")
https://gist.github.com/chrislkeller/5719258
I have no problem importing the json data into google spreadsheet, now the hard part is making the data update, I would really like it to auto update but even a "update now" button would be great.
Thanks,
This has been driving me nuts.
BV
So I was searching for a good way to do this as well. Here is what I have found so far.
If you change the function line of the importJSON like this:
function ImportJSON(url, query, parseOptions, recalc) {
}
Which just adds the recalc parameter to the function definition. This is a 'trick' because that parameter is not used for anything other than to make GSheet think something has changed.
Then in the call to ImportJSON (in a GSheet cell), you add in the function call like this:
=ImportJSON("https://yourDomain.com/something","","rawHeaders",A1)
Then in the sheet you can manually change the value of A1 to anything different than it is. The Sheet and all the imports will get refreshed.
Another ... non-technical trick ... manually change A1 to 1 then 2 then 3. Each time the sheet will recalc. Now you can use the UNDO and REDO buttons to change the numbers and recalc the sheet.
A little of a kludge Hack, but it does make for a one-button "recalc" of a sort.
You can just add the time trigger
https://developers.google.com/apps-script/understanding_triggers
File > Spreadsheet settings > Calculation > Recalculation: On change and every minute
Then you can insert a =now() column and it will refresh the sheet every minute.
Apologies if you've tried this already, I have it setup now in a sheet but am waiting for a live event to test, so it might not even work.
Im not really a javascript person, but I might have a little code that might help start you off. (Sorry if it does not help). What I use in my site is this (I changed it a little bit to incorporate your url).
$( document ).ready(function($) {
setInterval(function(){
$('.sell').load('http://api.796.com/v3/futures/ticker.html?type=weekly');
}, 5000);
});
This just grabs the JSON every 5 seconds, so be sure you parse the JSON and display the data you need. Hope this helps! :)