Get filtered data from Google Sheets API - node.js

I am using nodeJS for fetching the data from google sheet and the URL looks like :
var url = `https://sheets.googleapis.com/v4/spreadsheets/${sheet_key}/values/Sheet2!A1:J20?key=${google_API_key}`
From this, I am only getting the data between A1 to J20 So now I have two questions :
How do I get all the rows from the sheet or last 10.
How do I apply a structured query filter like: where name == "Himanshu"
Edited :
For question 2: what I have done is using Query Language Reference (Version 0.7) / structured queries, which is referenced by #Tanaike. This is how my URL looks
like now and its working as well.
https://docs.google.com/a/google.com/spreadsheets/d/${sheet_key}/gviz/tq?tq=select%20*%20where%20B%20%3D%20'Himanshu'&key=${google_API_key}
But the issue is it's returning me the string something like this which I cant able to parse.
google.visualization.Query.setResponse({"version":"0.6","reqId":"0","status":"ok","sig":"509770406","table":{"cols":[{"id":"A","label":"Response Path","type":"string"},{"id":"B","label":"Name","type":"string"}]}})

How about this answer?
A1
You can retrieve all rows using sheet name as the range as follows.
var url = `https://sheets.googleapis.com/v4/spreadsheets/${sheet_key}/values/Sheet2?key=${google_API_key}`
A2
You can use the query like where name == "Himanshu" using Query Language. In order to use this, please share the Spreadsheet as follows.
On Google Drive
On the Spreadsheet file
right-click -> Share -> Advanced -> Click "change" at "Private - Only you can access"
Check "On Anyone with the link"
Click "Save"
At "Link to share", copy URL.
Retrieve file ID from https://docs.google.com/spreadsheets/d/### file ID ###/edit?usp=sharing
About Query Language, you can see the detail information at Query Language Reference.
If I misunderstand your question, I'm sorry.
Edit 1 :
When you want to retrieve the formatted data, please use tqx=out:. In your case, tqx=out:json is used. It seems that it's default. For example, you want csv, it's tqx=out:csv. Also you can use tqx=out:html. I think that tqx=out:csv may be useful for your situation.
https://docs.google.com/a/google.com/spreadsheets/d/${sheet_key}/gviz/tq?tqx=out:csv&tq=select%20*%20where%20B%20%3D%20'Himanshu'&key=${google_API_key}
Edit 2 :
In order to retrieve JSON data of spreadsheet, please do as follows.
On Spreadsheet
Click File -> Publish to the web
Publish as web page.
URL 1
You can retrieve the values of spreadsheet as JSON using the following URL.
https://spreadsheets.google.com/feeds/cells/${sheet_key}/od6/public/values?alt=json
od6 means 1st page of spreadsheet.
URL 2
If you want to retrieve other pages, please confirm using the following URL.
https://spreadsheets.google.com/feeds/worksheets/${sheet_key}/public/basic?alt=json
Note :
If error occurs when you access the URLs, please confirm whether the spreadsheet is published again.

Related

Excel Web Query: Replace query URL with value from another table

Currently, the colorful table is using a fixed URL. I want to send a user-defined, complete URL string to this web query, and have it update whenever it's changed.
The large white box is a pulldown list (AN358):
User can choose a new location:
Which brings up a new URL (AN362) which points to a different web table (always same format). In my case, the colorful table does not change since it's currently a fixed link.
To the right, I converted the blue cells into a new table called "TableYear1" (AN361):
In power editor, here is the existing query "Year 1":
In advanced editor, I tried to replace the web link highlighted here:
With the underlined value here. I know the syntax/usage is probably wrong...it's just to illustrate what I want to accomplish.
try replacing the code with this
Source = Web.Page(Web.Contents(Excel.CurrentWorkbook(){[Name="TableYear1"]}[Content]{0}[URL1])),
in your example you pass a string (table name), while you need a reference to that table

Excel get data from web from dynamic table

I am trying to pull the full list of player data from https://stats.nba.com/players/traditional/?sort=PLAYER_NAME&dir=-1&Season=2019-20&SeasonType=Regular%20Season. However, the table is dynamic (URL doesn't change) so when I set up the connection Excel only scrapes the first 50 rows. It does not recognize that there are 6 other pages within the table that I need to scrape as well.
Does anyone know how to use the "Get Data" -> "From Web" capability in excel to import data from a dynamic table like the one shown above?
Instead of referencing the hosting page, why not use this endpoint that is returning the JSON data that populates the table? You just need to marry up the resultsSets.headers to the array positions within rowSet entries.
Edit: I found resources that explain the NBA REST API here: http://nbasense.com/nba-api/Stats/Stats/Players/AllPlayers . Take some time and review what's available. Any of those end-points can be consumed by Excel the way you are trying to.
Example:
https://stats.nba.com/stats/leaguedashplayerstats?College=&Conference=&Country=&DateFrom=&DateTo=&Division=&DraftPick=&DraftYear=&GameScope=&GameSegment=&Height=&LastNGames=0&LeagueID=00&Location=&MeasureType=Base&Month=0&OpponentTeamID=0&Outcome=&PORound=0&PaceAdjust=N&PerMode=PerGame&Period=0&PlayerExperience=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2019-20&SeasonSegment=&SeasonType=Regular+Season&ShotClockRange=&StarterBench=&TeamID=0&TwoWay=0&VsConference=&VsDivision=&Weight=
Sample of a Rowset showing Aaron Gordon. Per resultSets, 2nd field is Name, 5th is age... matches the table, and gives all players not just page 1.
"rowSet": [ [ 203932, "Aaron Gordon", 1610612753, "ORL", 24.0, 1, 1, ...
For brevity, that's just a sample and far from all of the info it returns. You can click that link and see the JSON data it's returning within your browser.

How to change text on page dynamically depending on value from another page/ product in Kentico CMS 9.0

Currently, we are working on Kentico CMS 9.0 version.
We are facing some development issue on below scenario:
There is a static message getting displayed on a Success page after
Registration. This Text is written in WebPart -- > HTML Envelop
section - Content after But we want to change this text dynamically
as per User selects the Band category.
Example If User registers for 1-10 Band category, then text message should be displayed as “ Fees $1, 500 / two years”, or if the range of 2-20, then “Fees: $2,500 / two years” etc.
We tried with Macros on this, but not getting the exact solution. Also tried with relating the pages to get value from this Category pages. But no luck.
If anyone has any pointers on this. Or whether it could be possible to do this in Kentico CMS, please let us know ASAP.
If the data the user is submitting is part of the user's record or attached to a user's ID you could do a lookup using a macro or create your own custom macro to do the work for you.
For instance, if the value the user selected is attached to the user's record and they are logged in after they register, you can use something like:
CurrentUser.GetValue("CustomFieldName")
This all depends on what the value is that you're storing. If you're storing an integer or key of some sort to another table, you'll need to get that key and do another lookup to that other table to get the actual display value. Something like this:
var userRegisteredValue = CurrentUser.GetValue("CustomFieldName");
GlobalObjects.CustomTables["CustomTableNamespace.CustomTableName"].Items.Where("ItemID = " + userRegisteredValue);

Excel Pivot Table: Open URL with Pivot Table Settings as Parameter

I have an Excel file that connects to our customer database. In there, I can break down the number of customers using a Pivot table. For instance, I would see that there are X female customers of age 18-25 who live in the US.
What I'd like to do now, is take this number X, turn it into a link that, when clicked, opens a web browser window to a web application which is also connected to the same customer database and does something with this specific customer segment (i.e. builds a contact file for a newsletter application etc.)
I have no idea how this can be done. I assume that it may be possible to add a custom button to the Excel toolbar which would extract all the current pivot table settings so that I can send them as URL parameters to my web app. Is this possible? If so, how is it done?
Can you help me in the right direction please?
Thx a lot!
No need to create buttons if you dont have to.
You can use the HYPERLINK() function and concatenate the URL out of text and cell values.
So for example the URL for this page in an excel cell would be:
=HYPERLINK("https://stackoverflow.com/questions/"&A1&"/excel-pivot-table-open-url-with-pivot-table-settings-as-parameter")
Where cell A1 = 18843796
18843796 being the id for this question. You can do this with as many parameters as you want.
This will create a clickable URL which will automatically open your default browser.

How to add variables (coming from a cell) in web queries in MS Excel 2010?

So, I have the excel sheet pulling data from web API call, which responds in xml format. I can successfully pull it, populate it, and work with it. And since it's a get call with some parameters appended to the query, I want those parameters to come from a cell in a separate sheet (in the same workbook) so that the user can change the cell instead of the query itself.
Is it possible? How do I do it? Will it make a new API call to get the data when the content of that cell is modified or does the user have to click on Refresh?
Thanks in advance!
UPDATE: I have tried to use something like this: http://finance.yahoo.com/q?s=[“symbol”, “Enter ticker symbol”] like defined here, but when I click Import, it gives me 404 and I just can't figure out how to do it.
The API call I'm making is to our Redmine machine and I'm using this Redmine API call

Resources