I'm getting confusion to start the code, could you please guide me to complete.
How to read the data from Google spreadsheet and store the data into variable using php
I have spreadsheet in Google Drive, I have data like:
s.no name mobilenumber
1 raghu 888888888
2 ram 777777777
I want to get the mobile number according to name condition:
if(name==ram){
mobile="";// have to store the particular number here
}
From spreadsheet using PHP
Related
This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I am trying to import data (industry) from yahoo finance to my google sheet tracker.
The formula below is able to extract the industry for every single stock that is listed on the US stock exchanges. However, when a stock is listed in Germany for example, and a suffix ".DE" needs to be added the formula stops working. I believe that the "." causes confusion to the URL somehow but cannot figure a way to fix it.
IMPORTXML("https://finance.yahoo.com/quote/"&$A2&"/";"//*[#id='Col2-12-QuoteModule-Proxy']/div/div/div/div/p[2]/span[2]")
Example
Now, with Yahoo Finance, the web page is built on the user side by javascript, not the server side. It is then completely impossible to retrieve information by importhtml or importxml. You need to parse the json called root.App.main.
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
var data = JSON.parse(jsonString)
For instance
https://docs.google.com/spreadsheets/d/1EKu4MbuwZ6OTWKvyIJrMfnXf7gXfU8TWU3jwV4XEztU/copy . If you need specific information, it is possible to adapt a small script to your needs.
I am trying to fetch current/ latest price from a dynamic content from National Stock Exchange (India) website in a cell in google sheets. The formula is:
=importxml("https://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=NIFTY&instrument=OPTIDX&strike=11400.00&type=CE&expiry=27SEP2018"),"//ul[#class='stock']/li[#class='active']/span[#id='lastPrice']")
Not getting the correct value.
Instead use =GOOGLEFINANCE("NSE:INFY", "all", DATE(2021,5,21), DATE(2021,6,24), "DAILY")
So I have shared a google workbook and I have created a key and so I can retrieve the structure of the workbook with the following link
Google Sheets - Copy of Guardian University Guide 2018
and in the results I can see the sheets in an array, so first element in an array has sheetId of 1544561606 so I presume somehow I can form a second url with this sheetId as well as original spreadsheet id and get the contents of the this sheet but the documentation is sparse IMHO. THen I can do the same for all the other sheets. I just can't find the correct url format. Please help.
This is version 4.0 of Google Sheets API.
From your endpoint, the sheet name of the sheet ID 1544561606 is "Institutional". You can retrieve the sheet data using this sheet name. The endpoint is as follows.
https://sheets.googleapis.com/v4/spreadsheets/1nDSd38lIQj_aTWDRPJ-aPybR0NwFdQ8GLSDJM0-QaR4/values/Institutional?key=AIzaSyBUHA34c7FmNLut1V7Pe3lIJTk3pX39J6E
Reference :
spreadsheets.values.get
If I misunderstand your question, I'm sorry.
I know how to query data from google spreadsheet with the general share link, but I want to pull data from specific tabs in that shared workbook. How do I do this?
It is not clear from your question how you are querying a spreadsheet (there are several ways to do it).
If you are using spreadsheet data source url (e.g: https://docs.google.com/spreadsheets/d/{ss_key}/gviz/tq?tq=...), then you can add gid or sheet url parameters to specify which sheet in the spreadsheet to query by its id or name:
https://docs.google.com/spreadsheets/d/{ss_key}/gviz/tq?gid=0&tq=...
https://docs.google.com/spreadsheets/d/{ss_key}/gviz/tq?sheet=Sheet1&tq=...
You can get the gid number of a sheet from the spreadsheet's url when it is open in your browser. More info here: https://developers.google.com/chart/interactive/docs/spreadsheets#Google_Spreadsheets_as_a_Data_Source
Note: data source url examples above are for new google sheets. If you are still using old sheets, the url format will be different: http://spreadsheets.google.com/a/google.com/tq?key=ABCDE&tq=.... The documentation link above still uses old sheets url format.
If you are querying your spreadsheet via QUERY() formula in another sheet, then just specify the name of the sheet you want to query in the data attribute of the function:
=QUERY('Example Data'!$A$2:$H$7, "select A where (B<>'Eng' and G=true) or (D > "&A2&")")
I read up on YQL. However i'm at a loss on how to get blocks of data.
I can get individual stock data fine but how do you get collated data like the FTSE 100 shares, without having to find the symbol for each 100 shares and pulling that data in individually?
Ideally i would have the hundred shares with each of their bits of data.
Thanks in advance,
Ewan
looks like you are right that only one stock can be queried at a time. since the api is restful, you can easily use a for loop in bash and curl all the stocks.
Whenever we query YQL table we need to give the SYMBOLS (tickers) as inputs. However there is a limit to the number of symbols you can enter in one go.
I created an Excel sheet where I read a list of symbols from a sheet and then query with YQL and dump the data in another sheet.
Let's assume you want to pull out historical prices with the following specifications:
Symbol/Ticker : symbol
StartDate
EndDate
The corresponding weblink to extract this info would be (in VBA syntax)
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20in%20%28%27 " & symbol & "%27%29%20and%20startDate%20=%20%27" & startDate & "%27%20and%20endDate%20=%20%27" & endDate & "%27&diagnostics=true&env=store://datatables.org/alltableswithkeys"
You can find the Excel sheet present at my blog.