Google Sheets - [Resource at URL not found] - google-sheets

Recently having issue with google sheets getting info from yahoo finance.
=if(isblank(B4),"",ImportXML("https://finance.yahoo.com/quote/"&B4&"/history?p="&B4, "//tbody/tr[1]/td[6]"))
*Cell B4 is ticker, example : [7113.KL]
Anyone encounter this?
Any solution for this?

Seems like IMPORT functions doesn't work on the link you provided. It might be that the data is javascript generated and it is a current limitation of IMPORT functions.
Easiest way to circumvent this is to find another site that its data isn't javascript generated. Such as this one.
Formula:
=INDEX(IMPORTXML("https://www.investingport.com/quotes/7113.KL/", "//div[#class='col-md-6']/span"),1,1)
Since your B4 contains 7113.KL and you check the B4 first
, then adjusted formula is:
=if(isblank(B4),"", INDEX(IMPORTXML("https://www.investingport.com/quotes/"&B4&"/", "//div[#class='col-md-6']/span"),1,1))
Sample output:
Alternative:
Another way is to do it via Apps Script using UrlFetchApp

Related

Export specific numbers from Sheets

So i have this column of numbers and i wish to extract only the numbers before the "HE" text for example, this is what i need, and i don't really know how to achieve this.
Maybe there is a way to use a formula or command to do this, i've been trying to use power tools add-on but to no avail i did not get it.
Maybe for clarification in each cell there are 2 lines, using alt+enter.
REGEXEXTRACT() is suitable in this case.
=REGEXEXTRACT(A1,"(.+) HE")
Few good tips here about REGEXEXTRACT().
For array approach use below formula-
=ArrayFormula(IF(A1:A="","",REGEXEXTRACT(A1:A,"(.+) HE")))

Broad match modifier Excel formula

Broad match modifier Excel formula
="+"&SUBSTITUTE(A1," "," +")
doesn´t seem to work in Google Sheets and LibreOffice. Every time I try, getting an error message. In LibreOffice error 501, In Google Sheets #ERROR. I use both in finnish language, so I have changed SUBSTITUTE for the finnish equivalent, still the same error...
Thanks for any help in advance.
I had to switch on the iterative setting in Google Sheets, now is working fine, thanks.

SUMIFS corrupting spreadsheets with PHPSpreadsheet

I am using PHPSpreadsheet and am reading in a spreadsheet with the following (working correctly) formula. I'm using Libre Office to generate my spreadsheet.
=SUMIFS($My_sheet.C:C,$My_sheet.B:B,">"&$'Home page'.$I$12,$My_sheet.B:B,"<"&$'Home page'.$I$13)
For some reason when I remove the offending rows my sheet reads/writes perfectly fine but with them I get corrupted files and it throws unreadable files.
I'm not setting the value - this is already in the spreadsheet I'm reading.
I hope this will help someone. I was looking for PhpOffice\PhpSpreadsheet\Calculation\Statistical\Conditional::SUMIFS() as your call.
For the example given simply wrap each , separated section in quotes and pass them to this function. So the answer would be:
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Conditional as StatCond;
StatCond::SUMIFS('$My_sheet.C:C','$My_sheet.B:B','">"&$\'Home page\'.$I$12','My_sheet.B:B','"<"&$\'Home page\'.$I$13')

Parsing Error trying to import Coinbase Pro API into Google Sheets

New to APIs in Google sheets, but I feel like I'm 95% of the way to where I'm trying to go.
I'm trying to pull crypto data into my spreadsheet to do a simple 24 hour price comparison and gauge whether the price has gone up or down, maybe use some conditional code to change the background to green or red. Simple enough. Most of the sites that offer APIs have given me various errors, though, so coinbase pro (and weirdly the deprecated gdax) have been most reliable (although I haven't ruled out that it started breaking because I'm now putting in too many call requests).
Found this as a way to get the current price of ETH, for instance:
=VALUE(SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTDATA("https://api.gdax.com/products/ETH-USD/ticker"),0,2), "price:",""), """", ""))
Works like a charm. So I changed the request to target different info, specifically the 24hr stats listed on the API doc, and the first value in that section, "open" for opening price (this ensures I get the price exactly 24hrs earlier). But I got a weird parsing error using the request, which is here:
=VALUE(SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,1), "open:",""), """", ""))
I've figured out the issue, but not the solution. Google Sheets says I am pulling in text. Because the "open" (opening price) value is the first listed in the JSON code, it is pulling in the code bracket from the nested HTML/JSON code. For instance, it says I can't parse "{open" into a number. And I get the same problem in reverse when I pull the last value listed in the stats section, which is "volume_30day:"
=VALUE(SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,6), "volume_30day:",""), """", ""))
This returns an error saying "volume_30day: #}" can't be parsed, so now it is the closing bracket of the JSON code. So I can't use "open" the first item in the API 24hr stats section, or Volume_30day, which is the sixth item on that list, but items 2-5 work just fine. Seems super weird to me, but I've tested it and it is seems to be what's going on.
There must be something stupid I need to tweak here, but I don't know what it is.
Answer 1:
About =VALUE(SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,1), "open:",""), """", ""))
When I checked =SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,1), "open:",""), """", ""), the value is {open:617. I think that when by this, when VALUE is used for the value, the error occurs.
In order to retrieve the values you expect, I would like to propose to use REGEXREPLACE instead of SUBSTITUTE. The modified formula is as follows.
=VALUE(REGEXREPLACE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,1), "open|""|{|}|:",""))
In this modified formula, open|""|{|}|: is used as the regex. These are replaced with "".
In this case, I think that =VALUE(REGEXEXTRACT(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,1), "\d+")) can be also used. But when I thought about your 2nd question, I thought that above formula might be useful.
Result:
Answer 2:
About =VALUE(SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,6), "volume_30day:",""), """", ""))
When I checked =SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,6), "volume_30day:",""), """", ""), the value is 7101445.64098932}. I think that when by this, when VALUE is used for the value, the error occurs.
In order to retrieve the values you expect, I would like to propose to use REGEXREPLACE instead of SUBSTITUTE. The modified formula is as follows.
=VALUE(REGEXREPLACE(INDEX(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"),0,6), "volume_30day|""|{|}|:",""))
In this modified formula, volume_30day|""|{|}|: is used as the regex. These are replaced with "".
In this regex, it can use by replacing open of open|""|{|}|: to volume_30day at above regex.
Result:
Other pattern 1:
As other pattern using the built-in formula, how about the following modified formulas?
=VALUE(TEXTJOIN("",TRUE,ARRAYFORMULA(IFERROR(VALUE(REGEXREPLACE(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"), "open|""|{|}|:","")),""))))
=VALUE(TEXTJOIN("",TRUE,ARRAYFORMULA(IFERROR(VALUE(REGEXREPLACE(IMPORTDATA("https://api.pro.coinbase.com/products/ETH-USD/stats"), "volume_30day|""|{|}|:","")),""))))
In these formulas, the values can be retrieved by replacing KEY of KEY|""|{|}|: of the regex.
Other pattern 2:
The returned value from https://api.pro.coinbase.com/products/ETH-USD/stats is the JSON value. So in this case, when the custom function created by Google Apps Script can be also used.
The Google Apps Script is as follows.
const SAMPLE = (url, key) => JSON.parse(UrlFetchApp.fetch(url).getContentText())[key] || "no value";
When you use this script, please copy and paste the above script to the script editor of Spreadsheet and save it. And please put the custom function like =SAMPLE("https://api.pro.coinbase.com/products/ETH-USD/stats","open") and =SAMPLE("https://api.gdax.com/products/ETH-USD/ticker","price") to a cell. By this, the value can be retrieved.
References:
REGEXREPLACE
Custom Functions in Google Sheets

Calling an Excel formula from server-side Ruby web application

My customer has a coded a function that takes 20 boolean values and comes up with an integer result.
They did it with Excel, as a complex formula.
In a new ROR web application, am I better off recoding the whole thing in Ruby, or somehow calling the Excel formula?
I could try to contact a server-side instance of Excel or headless OpenOffice and communicate with it using JACOB or the OpenOffice API?
You can use the spreadsheet gem to read from the Excel file. Try the following code, using a sample file in the same directory called ss.xls which has 1 in A1, 2 in B1, and =A1+B1 in C1.
#gem install spreadsheet
require 'spreadsheet'
book = Spreadsheet.open('ss.xls')
sheet = book.worksheet('Sheet1')
puts sheet.row(0)[2].value
The value call returns the last value for the cell that was calculated by Excel, with the above example it will output 3.0
Edit: Read more about the gem here: http://spreadsheet.rubyforge.org/GUIDE_txt.html
Edit 2: Of course, if you happen to be on Windows you will not need a gem; you just can use the win32ole library as described here: http://www.ruby-doc.org/docs/ProgrammingRuby/html/win32.html
No answers, so for now I will guess that re-implementing the formula in Ruby is less difficult than calling Excel/OpenOffice.
Feel free to provide a better answer!

Resources