ImportXLM on Google Sheets - google-sheets

I am having a hard time extracting only the title of a Spotify playlist name to google sheets.
Here is the link: https://open.spotify.com/playlist/37i9dQZF1DX0jgyAiPl8Af?si=xeoueUTuR0uNfk4kYSmnZg
Here is my current code: =IMPORTXML(B2,"//head/title")
(B2 is the link)
Here is what it prints: Peaceful Guitar | Spotify Playlist
I am trying to figure out how to only get the peaceful guitar part. I'm not sure how I would go about this so any help would be highly appreciated!
Thanks!

In your situation, how about retrieving the value from meta tag using a xpath?
Modified formula:
=IMPORTXML(A1,"//meta[#property='twitter:title']/#content")
In this case, the cell "A1" has the URL of https://open.spotify.com/playlist/37i9dQZF1DX0jgyAiPl8Af?si=xeoueUTuR0uNfk4kYSmnZg.
Or, you can also use =IMPORTXML(A1,"//meta[#property='og:title']/#content").
Or, you can also use =IMPORTXML(A1,"//div[#class='media-bd']/h1/span[#dir='auto']").
Result:
Note:
For example, when you want to retrieve the value of Peaceful Guitar using your formula, you can also use the formula of =TRIM(INDEX(SPLIT(IMPORTXML(A1,"//head/title"),"|"),1)).
Reference:
IMPORTXML

Related

Very Specific Filtering in Google Sheets

I am making a calculator in Google sheets and I would like to find a formula or script or something that will allow me to read the value of a certain square and add the formula "=sum(C5:C9)" or "=product(C5:C9)" or whichever depending on what the person puts in C4. Not sure if this is possible in google sheets (without custom code), but if it is, that would be great!
try:
=IF(C4="*"; PRODUCT(C5:C9); SUM(C5:C9))

Google Sheets ImportXML on Coinmarketcap.com

I have a google sheet that I use to track crypto positions and I'm using ImportXML to grab the current price of the coin off of coinmarketcap.com. All of them work with the same set of parameters:
URL https://coinmarketcap.com/currencies//
Full XPath: /html/body/div[1]/div[1]/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div/span
Formula:
=IMPORTXML("https://coinmarketcap.com/currencies/the-sandbox/", "/html/body/div[1]/div[1]/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div/span", "en US")
This works for every coin I've tried EXCEPT SAND (https://coinmarketcap.com/currencies/the-sandbox/) and I've no clue why. I have tried pretty much every combination of the path I can think of.
Does anyone have any ideas? I am totally stuck on this one.
try:
=IMPORTXML("https://coinmarketcap.com/currencies/the-sandbox/";
"//div[#class='priceValue ']")
If you want have pure number without $ try this:
=VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IMPORTXML("https://coinmarketcap.com/currencies/ethereum/"; "//div[#class='priceValue ']") ;"$";"");",";"");".";","))

Extract html table row to google sheet

I’m trying to extract a single row from a table
When using the google sheet importhtml function, I get the whole table.
=IMPORTHTML("https://www.marketwatch.com/investing/stock/jwn/options?mod=mw_quote_tab", "table",1)
How can I extract just the row right above the word “ Current price as of “
So e.g. in this case the row will have the data below. (this data will change as the date changes)
quote 1.5 0.53 76 1.36 1.47 142 39 quote 0.88 -1.73 23
I have several urls to go thorough
So e.g if I put the following url then the row position will change.
https://www.marketwatch.com/investing/stock/ge/options
Any idea how to extract that just last row right above the word “ Current price as of “
When I saw the HTML data from the URL of https://www.marketwatch.com/investing/stock/ge/options, I thought that the value you expect might be able to be retrieved using IMPORTXML and a xpath. So in this answer, I would like to propose to use IMPORTXML.
Sample formula:
=IMPORTXML(A1,"//tr[td[1]/#class='acenter inthemoney'][last()]")
In this case, the URL of https://www.marketwatch.com/investing/stock/ge/options is put in the cell "A1".
Result:
Note:
This sample formula can be used for the current URL of https://www.marketwatch.com/investing/stock/ge/options. So when the URL is changed and the HTML structure is changed by updated of the site, the formula might not be able to be used. So please careful this.
Reference:
IMPORTXML
ImportHTML() simply allows you to read an (entire!) HTML table or list into your Google sheet.
If you want to filter or manipulate the imported data, then you'll need to use other Google Sheets functions. These are documented here:
Google Sheets function list
Alternatively, you might want to "import" input one sheet, then select certain data into another, separate sheet:
Get data from other sheets in your spreadsheet
Here are some examples for "filtering" your data:
FILTER function

Cell/column/row divider between formula/import result

This is a Google Sheets case, but if you good enough with MS Excel and
know the solution, don't be shy and share it with the community. Your
experience could be relevant to all of us.
Hello over there! I still didn't find any relevant solution in google, so I post my problem here.
I have a sample sheet and I import data via formula to cell via:
=UNIQUE(INDIRECT(C$2&"!"&$O3)
which means import all unique values via formula from Sheet!Range:range
It works fine, and I receive necessary data like:
But I want to see it like this:
with X (1,2,3,etc) row/cell/column spaces between them. I guess that =SPLIT formula should help me with that, but when I use , as a separator, I receive only first value, not the whole array of results that I needed it to.
So is there any way to achieve the result that I show at the picture above via formula or Google Script?
SAMPLE TEST SHEET with EDIT permission here:
https://docs.google.com/spreadsheets/d/1eYeFI8nL39kLNDkcyyjeqV8tc9LwG7P7cn2NzUIB7Wo
=ARRAYFORMULA(SUBSTITUTE(TRANSPOSE(SPLIT(QUERY(
"♂"&UNIQUE(INDIRECT(F$2&"!"&$G2))&"♂♀",,999^99), "♂")), "♀", ""))

extract data from Google spread sheets using imcaro

I'm trying to extract a cell value from a Google spreadsheet using imacro script.
This is the spread sheet I'm working on.
And I need to get the Cell 'A1' value.
Below is my try, and it is not working.
TAG POS=2 TYPE=A ATTR=TXT:https://www.ebay.com* EXTRACT=TXT
Please help.
One of the possible (simplest) ways is to use Google Query Language for requesting necessary data and extract them afterwards. Something like this:
URL GOTO=https://docs.google.com/spreadsheets/d/13akuXU0cp047_6VFdtUgdn2fKfhPilF_hPHrnTNV164/gviz/tq?tqx=out:html&tq=select%20A%20limit%201
TAG XPATH="//tr[last()]/td" EXTRACT=TXT
Keep in mind that your spreadsheet must be shared in this case.

Resources