How can I grab the XML data using Google Sheets - regex

Google sheet has a function importxml() to grab data from a webpage, I want to grab the table from https://rss.weather.gov.hk/rss/CurrentWeather.xml, it is an XML with XSL when I view the page source, I find the <td> tag, I try to input
=IMPORTXML("https://rss.weather.gov.hk/rss/CurrentWeather.xml", "//td")
in the cell but it returns #N/A, what is the syntax error I made? Or the content format not acceptable to Google Sheets?

=ARRAYFORMULA({IFERROR(REGEXEXTRACT(TRANSPOSE(SPLIT(INDEX(IMPORTXML(
"https://rss.weather.gov.hk/rss/CurrentWeather.xml", "//*"), 21, 1),
CHAR(10))), "(.*) \d+ degrees ;"), TRANSPOSE(SPLIT(INDEX(IMPORTXML(
"https://rss.weather.gov.hk/rss/CurrentWeather.xml", "//*"), 21, 1),
CHAR(10)))), IFERROR(REGEXEXTRACT(TRANSPOSE(SPLIT(INDEX(IMPORTXML(
"https://rss.weather.gov.hk/rss/CurrentWeather.xml", "//*"), 21, 1),
CHAR(10))), "\d+ degrees ;"))})

Related

SubString match in Google Sheets using Regex and Query

This is the data in google sheets
Account Numkber Names
7728550,543216 Govt Req
772855,65432 Vodafone
I am trying to do a lookup of the account numbers with the formula
=QUERY(Sheet1!B$3:C$4,"Select C where B matches '^.*(" & B2 & ").*$' limit 1")
772855 - Govt req
How do I solve this ? There is a large chunk of data so I can't paste the values in different rows.
use:
=ARRAYFORMULA(IFNA(VLOOKUP(B2:B,
SPLIT(FLATTEN(SPLIT(Sheet1!F2:F, ",")&"×"&Sheet1!G2:G), "×"), 2, )))

vlookup google sheets first and last name compare

Okay so i have a this formula:
=ArrayFormula({"Manager:";IF(D5:D="",,IFERROR(VLOOKUP("*"&REGEXEXTRACT(D5:D,"[a-zA-Z]+")&"*",'Client-Manager'!A:B,2,FALSE),"NO MATCH"))})
It works fine with what i have it doing now but i'm running into a problem now were i need to compare both last and first name and i can't figure out how to do it.
Here is an example sheet:
Sheet im working with
Im comparing in "work-order" sheet column D with and in "manager" sheet column A to then output back on "work-order" sheet column G.
Formula i'm working with resides in "Manager" cell in "work-order" sheet in column G
try:
=ARRAYFORMULA({"Manager:"; IF(D5:D="",,
IFERROR(VLOOKUP("*"&REGEXEXTRACT(REGEXREPLACE(D5:D, ",", ),
"[a-zA-Z ]+")&"*", 'Client-Manager'!A:B, 2, ),
IFERROR(VLOOKUP("*"&REGEXEXTRACT(D5:D,
"[a-zA-Z]+")&"*", 'Client-Manager'!A:B, 2, ), "NO MATCH")))})

How to get a specific value from a Cell which has a lot of data

I want to get only the price's encased in brackets in Price EUR cell:
Sheet link: https://docs.google.com/spreadsheets/d/1xoNPfIfrVv7jF8W3Pa67Iu9oJRz2NOncW7oLQ94mWQ4
try:
=IFNA(INDEX(TRIM(ARRAY_CONSTRAIN(SUBSTITUTE(
SPLIT(REGEXEXTRACT($A3, B1&"(.+)"), "]"), "[", ), 1, 2))), 0)

How to fix error "404" in Power BI M query

I am getting error code 404 in PowerBI.
Sample Data:
ID, text
1, #VirginAmerica What #dhepburn said.
2, #VirginAmerica plus you've added commercials to the experience..
3, #VirginAmerica I didn't today... Must mean I need to take another
4, "#VirginAmerica it's really aggressive to blast obnoxious ""entert
5, #VirginAmerica and it's a really big bad thing about it
I am trying to write sentiment score in PowerBI using M query in Microsoft cognitive services.
below is my query.
Query: (Source as table) as any =>
let JsonRecords = Text.FromBinary(Json.FromValue(Source)),
JsonRequest = “{“”documents””: ” & JsonRecords & “}”,
JsonContent = Text.ToBinary(JsonRequest, TextEncoding.Ascii),
Response =
Web.Contents(“https://westcentralus.api.cognitive.microsoft.com/text/analytics”,
[
Headers = [#”Ocp-Apim-Subscription-Key”= APIkey,
#”Content-Type”=”application/json”, Accept=”application/json”],
Content=JsonContent
]),
JsonResponse = Json.Document(Response,1252)
in
JsonResponse (Query end)
Error:
An error occurred in the ‘’ query. DataSource.Error: Web.Contents failed to get contents from 'https://vizguru.cognitiveservices.azure.com/text/analytics/v2.1/sentiment/keyPhrases' (404): Resource Not Found
Details:
DataSourceKind=Web
DataSourcePath=https://vizguru.cognitiveservices.azure.com/text/analytics/v2.1/sentiment/keyPhrases
Url=https://vizguru.cognitiveservices.azure.com/text/analytics/v2.1/sentiment/keyPhrases
Expected Output:
ID, text, Score,
1, #VirginAmerica What #dhepburn said., 2
2, #VirginAmerica plus you've added commercials to the experience..., 3
3, #VirginAmerica I didn't today... Must mean I need to take another !,4
4, #VirginAmerica it's really aggressive to blast, 5
5, #VirginAmerica and it's a really big bad thing about it, 6
Steps Followed from this link.
Please suggest a solution.
Thanks,
Shiva
Yes, I can repro your 404 error on my side . The reason is the text analysis endpoint:
https://westcentralus.api.cognitive.microsoft.com/text/analytics
not works anymore .
If you want to use azure cognitive service text analytics API, pls refer to this guide to find correct endpoint and ways to call text analysis service .
If you have any further concerns ,pls feel free to let me know .

Regex in google sheets - Extract parts of URL between slashes

I have difficulties with extracting parts of URL.
What I need is to know what category the product is(jeans, socks, tshirts), and a subcategory what color the product is(blue, black, white)
https://www.examplewebsite.com/shop/jeans/blue/123456
https://www.examplewebsite.com/shop/socks/black/234567
https://www.examplewebsite.com/shop/tshirst/white/4321
What is the best way to extract this in google sheets?
Please try:
=index(split(A1,"/"),,4)
and
=index(split(A1,"/"),,5)
copied down to suit.
={"PRODUCT", "CATEGORY";
INDEX(SPLIT(A2:A, "/"), , 4),
INDEX(SPLIT(A2:A, "/"), , 5)}