I'm trying to use Xpath to grab in rows of a table containing images and text. Things work fine as long as images are present as on this 3rd table on this page. But when images are missing as in the table as on this page it doesn't work. I need to connect the image with the right row of table data.
Here's the type of xpath_query strings I've been using in google sheets, where A1 contains the url.
=importXML(A1,"//tbody//img/#src")
=importXML(A1,"//tbody//tr")
Thanks for any help.
Shorter alternative with XPath filtering (url in C2, formula in I27) :
=ARRAYFORMULA({{"figura:";IMAGE("https://www.patentati.it/"&IMPORTXML(C2;"//tr//img/#src|//tr[not(.//img)]/td[#class='domanda']"))}\QUERY(IMPORTHTML(C2;"table";1);"select Col2,Col3")})
Output :
Sidenote : I'm based in Europe. Formula for US locales :
=ARRAYFORMULA({{"figura:";IMAGE("https://www.patentati.it/"&IMPORTXML(C2,"//tr//img/#src|//tr[not(.//img)]/td[#class='domanda']"))},QUERY(IMPORTHTML(C2,"table",1),"select Col2,Col3")})
like this:
=ARRAYFORMULA(IMAGE("https://www.patentati.it"&TRIM(SUBSTITUTE(FLATTEN(
SPLIT(QUERY(IFNA(REGEXEXTRACT(QUERY(ARRAY_CONSTRAIN(IMPORTDATA(A1), 500, 1),
"where Col1 matches '.*zoomImage.*|.*rowspan.*'"),
"src=""(.+png)"), "♀♫"),,9^9), "♫")), "♀", ))))
and a whole table:
=ARRAYFORMULA({{"figura"; IMAGE("https://www.patentati.it"&TRIM(SUBSTITUTE(FLATTEN(
SPLIT(QUERY(IFNA(REGEXEXTRACT(QUERY(ARRAY_CONSTRAIN(IMPORTDATA(A1), 500, 1),
"where Col1 matches '.*zoomImage.*|.*rowspan.*'"),
"src=""(.+png)"), "♀♫"),,9^9), "♫")), "♀", )))},
QUERY(IMPORTHTML(A1, "table", 1), "select Col2,Col3", 0)})
Related
Issue with an incomplete import in google sheet
Following this thread :
VLOOKUP + QUERY + IMPORTRANGE > import all lines with condition true
I have a list of spells that today exceeds 1010 items.
The source data is imported in different spreadsheets with the following formula that does work : =ARRAYFORMULA(IFNA(VLOOKUP(A3:A; QUERY({IMPORTRANGE(A1; I1)}; "select Col2,Col1,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15 where Col1=TRUE"; ); {3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15}; )))
However, I reach a limit at row A1001 ; the following wont get filled with any data even though the remaining items in the source data followed the query rules.
I import a table of 15 columns, so I was wondering if there was a limit of 15*1000 cells in google sheet and if so, what was the best way of getting the extra rows.
Thanks !
Try inserting in Sheet 2 the full QUERY:
=QUERY({IMPORTRANGE(Sheet1!A1;Sheet1!I1)}; "select Col2,Col1,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15 where Col1=TRUE"; )
(PS: I'm guessing your first sheet is called Sheet1, please check it)
And in Sheet1 you can use FILTER:
=BYROW(A3:A,LAMBDA(each,IFNA(FILTER(Sheet2!B:O,Sheet2!A:A=each))))
Let me know!
I have a Google Sheet that has a cell that I want to use as a drop-down filter for another range within the sheet.
You can take a look at the sheet HERE.
Cell G11 is the cell that I wish to have the drop-down filter in.
Range B15:H69 is the range that should be filtered upon using this filter.
So, for example - if I select 'Barbarian' in the G11 drop-down the sheet should go from something like this (cut short for size of post sake):
To something like this:
I've tried using Named Ranges, using a seperate sheet to filter the data, and a couple other methods I found. Nothing seems to work exactly how I want it to, like in picture #2.
try:
=INDEX(LAMBDA(x, SPLIT(FLATTEN(SPLIT(FLATTEN(QUERY(TRANSPOSE(x),,9^9))&"×", "×")), " "))
(QUERY({ROW(Data!A2:D), SORT(Data!A2:D, 3, 0)},
"select Col1,Col2,'♀',Col3,Col4,'♂',Col5 where Col3 = '"&G11&"' label'♀''','♂'''")))
UPDATE:
=INDEX(LAMBDA(x, SPLIT(FLATTEN(SPLIT(FLATTEN(QUERY(TRANSPOSE(x),,9^9))&"×", "×")), " "))
(QUERY({ROW(Data!A2:D)-1, SORT(Data!A2:D, 3, 0)},
"select Col1,Col2,'♀',Col3,Col4,'♂',Col5 where 2=2 "&IF(
REGEXMATCH(G11, "(?i)all|n\/a|^$"),," and Col3 = '"&G11&"'")&" label'♀''','♂'''")))
I've been working on a spreadsheet with over 100 rows, and found a hacky way to incorporate a "hide" checkbox that will hide any row where column C matches a specific value (building type), specified beside the box. To do this, I first created a function like this: =FILTER(Data!A1, OR(Data!$C1<>$O$2, $P$2)) and dragged that across every row and column in a seperate sheet. This reads as, "Display current cell if the corresponding column C in that row in Data does not match the building type, or if the the checkbox is checked. This way, the whole row is hidden when the building type matches, and the box is unchecked. A1 adjusted to each row individually, $C1 referenced the building's type, $O$2 referenced the targeted type to potentially hide, and $P$2 was the checkbox.
Problem #1: This created a lot of formulas in hundreds of cells, and when the building type was not found, it displayed #N/A across the entire row. A Filter View was able to hide these values, but it was inconvenient to have to reset the values every time I wanted to hide or unhide another building type.
My Attempt to Fix: I used a filter function once again to recreate the entire sheet from one cell, hiding the appropriate rows, using this: =FILTER(Data!A2:J191, ARRAYFORMULA((Data!$C2:C191<>$O$2)+(Data!D2:D191*$P$2)) This is the hacky part. I multiplied the checkbox's "true" by an array arbitrary positive numerical values in the D column to "OR" it with each building type value to achieve the same goal as before, but for EVERY cell.
Problem #2 arose: When I get my beautiful sheet, I can not sort it via a filter view, or it will throw an error and display nothing. I'm resorting to sorting the original tab, but intend to have it be ignored entirely. So how do I combine these two, Filter View, and Filter Function, to create a nice spreadsheet where I can SORT AND HIDE rows?
Bonus Problem #3: To add more buttons, my formula is this: =FILTER(Data!A1:J191, ARRAYFORMULA((Data!$C1:C191<>$O$2)+(Data!D2:D192*$P$2)), ARRAYFORMULA((Data!$C1:C191<>$O$3)+(Data!D2:D192*$P$3)), ARRAYFORMULA((Data!$C1:C191<>$O$4)+(Data!D2:D192*$P$4)), ARRAYFORMULA((Data!$C1:C191<>$O$5)+(Data!D2:D192*$P$5)), ARRAYFORMULA((Data!$C1:C191<>$O$6)+(Data!D2:D192*$P$6)), ARRAYFORMULA((Data!$C1:C191<>$O$7)+(Data!D2:D192*$P$7)), ARRAYFORMULA((Data!$C1:C191<>$O$8)+(Data!D2:D192*$P$8)), ARRAYFORMULA((Data!$C1:C191<>$O$9)+(Data!D2:D192*$P$9))) This is ugly, and very slow to load. Is there a way to create a function range to handle the same checks on multiple rows, and crunch it into a single formula?
Here is another monstrosity (this one has less repetition) for you:
=QUERY(
{IGNORE!A2:J, IGNORE!P2:P},
"SELECT * "
& "WHERE Col3 is not null "
& IF(COUNTIF(P2:P9, False) = 0, "", "AND NOT Col3 MATCHES '^" & JOIN("$|^", IFNA(FILTER(O2:O9, P2:P9 = False))) & "$' ")
& IF(COUNTIF(A2:K2, ">0") = 0, "", "ORDER BY Col" & JOIN(", Col", IFNA(FILTER(COLUMN(A2:K2) & IF(COLUMN(A2:K2) = 1, "", " DESC"), A2:K2)))),
0
)
Your checkboxes should remain. The second row can have just True/False values, no need for column number (a simple change will be needed COUNTIF(A2:K2, ">0") -> COUNTIF(A2:K2, True)). Also consequent sort works now (but only in the actual order of columns: if checked 1, 3, 4 then it will be sorted first by 1, then by 2, then by 4). You could place another config table on the right about sorting, where you would select all the columns you wish to sort by, their mutual order, and desc/asc for them.
Edit: added IFNA so FILTER won't return an error, changed multiple ANDS to MATCHES and simple regexes.
I am currently trying to use google sheets to sort a table based on the unique values found in only two of the columns.
What I want to happen is that columns A (Brand) and B (Dimensions) are both checked for unique values, removing any duplicate data.
The problem is using these two columns to filter and show the rest of table. I can't managed to achieve it.
Original Data
What is should look like after being culled
.
You can use Query function:
=query(A1:D8,"select A, B, min(C), min(D) group by A, B",1)
Example spreadsheet
try:
=ARRAYFORMULA(SORT(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(SORTN(
IF(A2:C<>"", {"♦"&A2:A&"♦"&B2:B, "♦"&C2:D}, ), 99^99, 2, 1, 1))
,,99^99)), "♦"), 2, 1))
Folks,
I've column [A] with various texts and need to transform that text (i.e., replace with abbreviations) before loading.
So, a table has values: J1, J2, J3, PLAB, CIVIL, ENGG etc.
I need to transform it to "J1" to "Java", "J2" to "Stack", while keeping the PLAB, CIVIL & ENGG as they are.
Hope I am clear.
PS: I don't need a calculated column, as column [A] has other text that does not need transformed.
This can be done when you add the data table to the analytic.
File > Add Data Table > (Select your data)
At the bottom of the window, you will see Transformations... select Calculate and replace column
Add the expression below, and give it the same column name as the original column
Select OK
Custom Expression:
case
when [yourColumn] = 'J1' then 'Java'
when [yourColumn] = 'J2' then 'Stack'
else [yourColumn]
end