Exporting Table Data to Google Spreadsheet via XPath - xpath

I´m trying to export table data to Google Spreadsheet by using the importxml command and XPath but it doesn´t work. A parser error appears, which says that there´s an error while parsing the formula.
I want to get the mobile PIs from this page: http://ausweisung.ivw-online.de/index.php?i=1121&a=a9170
I tried a command like this: =IMPORTXML("http://ausweisung.ivw-online.de/index.php?i=1121&a=a9170"; "//*[#id="ibody"]//div[1]/div/div[3]/div[2]/table/tbody/tr[4]/td[5]")
As mentioned in the comments below, I also want to perform the request more dynamic. I want to search for a specific string and then jump to a column of my choice.

There is a formula error because you use double quotes (") inside other double quotes. You have to use single quotes inside a string that is delimited by double quotes.
=IMPORTXML("http://ausweisung.ivw-online.de/index.php?i=1121&a=a9170", "//*[#id='ibody']//div[1]/div/div[3]/div[2]/table/tbody/tr[4]/td[5]")
The result is still #N/A, presumably because your path expression does not match anything.
EDIT
I´m looking for the right xpath command to get (in this case) just the data '11.824.563'.
The correct expression to retrieve this value would be:
=IMPORTXML("http://ausweisung.ivw-online.de/index.php?i=1121&a=a9170", "//div[#class='statistik']/div[#class='uebersicht']/table/tr[3]/td[2]")
But unfortunately, IMPORTXML is so buggy and unreliable that this still yields "#N/A" as a result. This seems to have worked in older versions of Google Spreadsheets:
https://productforums.google.com/forum/#!msg/docs/yWPaNDK0Kpg/3UIIeDA0SAIJ

Thanks to a user from the Google product forums I got the right formula to solve my request correctly.
=arrayformula( value( regexreplace( query( importHTML("http://ausweisung.ivw-online.de/index.php?i=112&mz_szm=201408"; "table"; 3) & ""; "select Col5 where Col3 = 'GLAMOUR (Smartphone-Apps)' "; 0 ); "[^\d]"; "" ) ) )
This request is looking for a specific string in a specified table, and grabs the data from the fifth column in this row.

Related

Match part of the text and replace with another text in excel

I've data table with list of names which are having few differences. I am trying to change those text to similar name within data table as image in below.
If part of the text in cells in data table are matching with the "Abbreviations" list(Col-AK) then Data table text must replace with the text in "To be replaced" (Col-AL) into "Expected Return Table". I've tried using may different functions to accomplish my ultimate target, but none of them is giving perfect answer.
Can anybody help me with this problem.
I found an answer to my problem. I could do this using below formula.
Step 01:- I've used below static formula at first to identify the dynamic formula
=IF(LEFT(AC2,4)=$AK$2,$AL$2,AC2)
Step 02:- Then I've used Index function to return the first text in abbreviation list which is Iodine by only changing partial of the formula to return only single value avoiding others. Ex: Firstly I considered only about the Iodine in the list. This will only replace Iodine into the expected data table.
=IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,1),$AL$2,AC2)
Step 03:- Then row_num turned into dynamic and expanded the return text data into range($AL$2:$AL$11) from single($AL$2) using Match & Left function as below.
=IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),INDEX($AL$2:$AL$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),AC2)
Step 04:- Finaly ignore errors using IFERROR Function.
=IFERROR(IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),INDEX($AL$2:$AL$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),AC2),"")
Expected Return Data Table as shown below.

Use limits with numerical cell reference in Google Sheets Query

I have a query on my Google Sheet in which I use a cell reference in the 'where' condition. The formula is similar to the following example. The referred cell 'F2' contains only numerical data, hence the &F2 after the double quotes. This query statement works fine and the output is as expected.
=query(DataRange,"select A,B,F where D>="&F2)
However, I need just one result (the first occurrence) as output and would like to use the 'limit' function. I can't figure out how or where I should insert 'limit 1' in this query. Any help is appreciated.
=query(DataRange,"select A,B,F where D>="&F2 & " limit 1 offset 0")

How to add filter to excel table in UI Path?

I have an excel file with a table named 'Table1' in it. I have to perform 'Filter Table' activity in UiPath with the condition "column1 begins with '*my column'". But when I specify the value like this, the column is filtered for 'ends with' operation.
Here is the screenshot for my table-
Below is the screenshot for the steps I followed-
This has been answered many times on UiPath Forum
For example https://forum.uipath.com/t/filter-table-in-excel-data-tables/559/3
If you use *my value as the search / filter pattern, then it'd mean, anything in the beginning and must have my value in the end. So, it is being interpreted correctly as Ends With. If you want to have a Begins With filter, you should have your filter text followed by the wildcard, like - my value*.
Further, if you want to include wildcard as a literal in the search pattern, you'd need to escape that by enclosing it in brackets like [*]my value* - this'd search for text beginning with *my value.
MS Excel / VBA also supports Tilde ~ as an escape character in some cases.
In excel filters, '' represents any series of characters.
The issue in the above case is that the filter value in the condition already contains a ''. Because of this, system always reads it as '*My column' => '[any characters]My column'. i.e., value ends with 'My column'.
To resolve this issue, I have specified contains filter instead of Begins with as 'My column'.
I have also tried to escape '*'. But it threw excel exception.
In addition, you can not specify condition as "Column1 Like '*My column%'". This works file when you are adding filter to 'DataTable'(after performing 'ReadRange' activity). But in this case, you will retrieve all the records and then you will be filtering the columns. This will lead to performance issues if the the excel table is huge.
You can follow the syntax below to perform filter activities in an excel:
DataTableName.Select("[ColumnName]='Datawithwhichweneedtofilter’").CopytoDataTable()

Why is this function throwing a filter error?

I'm working with a Google Spreadsheet that's pulling data from another sheet if certain conditions are met. Well, at least that's what it should be doing—instead, I'm getting "No matches are found in FILTER evaluation."
The function is:
=filter(importRange("https://docs.google.com/spreadsheets/d/1Z_7hl4uEc-an2rOUgOd_zYhCeb_QNIZopahJqBYooRg/edit#gid=0", "Sheet1!R2:R5000"), SEARCH( A3 , index(importRange("https://docs.google.com/spreadsheets/d/1Z_7hl4uEc-an2rOUgOd_zYhCeb_QNIZopahJqBYooRg/edit#gid=0", "Sheet1!V2:V5000")) ) )
I've tried it with a variety of row and column parameters for the index() function. I've also tried adding * to the beginning and end of the search term in A3, in case that's the issue. I've also tried putting quotes around the value in A3.
What am I missing? Sample spreadsheet is here.
I can't find a reference at the moment, but there is a known issue associated with the fact that the newest version of Sheets requires that you explicitly allow access to the other sheet via ImportRange. The issue is, when the ImportRange is nested, it doesn't give the opportunity to allow access - it will just return a #REF error inside your formula.
The work around is to just invoke the ImportRange by itself first (you could use a smaller range):
=ImportRange("https://docs.google.com/spreadsheets/d/abcdefg","Sheet1!R2")
then "Allow access" when prompted; then nest it in your formula.
As an aside, it is advisable to use ImportRange as few times as possible, so in your case it might be better to use QUERY:
=QUERY(ImportRange("https://docs.google.com/spreadsheets/d/abcdefg","Sheet1!R2:V5000"),"select Col1 where Col5 contains '"&A3&"'",0)
You can cheat the IMPORTRANGE issue by having a page which just pulls a single cell from every sheet you want to reference nested. Once it's been given permission the permission persists throughout the sheet.

How do I return multiple columns of data using ImportXML in Google Spreadsheets?

I'm using ImportXML in a Google Spreadsheet to access the user_timeline method in the Twitter API. I'd like to extract the created_at and text fields from the response and create a two-column display of the results.
Currently I'm doing this by calling the API twice, with
=ImportXML("http://twitter.com/status/user_timeline/matthewsim.xml?count=200","/statuses/status/created_at")
in the cell at the top of one column, and
=ImportXML("http://twitter.com/status/user_timeline/matthewsim.xml?count=200","/statuses/status/text")
in another.
Is there a way for me to create this display with a single call?
ImportXML supports using the xpath | separator to include as many queries as you like.
=ImportXML("http://url"; "//#author | //#catalogid| //#publisherid")
However it does not expand the results into multiple columns. You get a single column of repeating triplets (or however many attributes you've selected) as shown below in column A.
The following is deprecated
2015.06.16: continue is not available in "the new Google Sheets" (see: The Google Documentation for continue).
However you don't need to use the automatically inserted CONTINUE() function to place your results.
=CONTINUE($A$2, (ROW()-ROW($A$2)+1)*$A$1-B$1, 1)
Placed in B2 that should cleanly fill down and right to give you sane column data.
ImportXML is in A2.
A3 and below are how the CONTINUE() functions are automatically filled in.
A1 is the number of attributes.
B1:D1 are the attribute index for their columns.
Another way to convert the rows of =CONTINUE() into columns is to use transpose():
=transpose(importxml("http://url","//a | //b | //c"))
Just concatenate your queries with "|"
=ImportXML("http://twitter.com/status/user_timeline/matthewsim.xml?count=200","/statuses/status/created_at | /statuses/status/text")
I posed this question to the Google Support Forum and this is was a solution that worked for me:
=ArrayFormula(QUERY(QUERY(IFERROR(IF({1,1,0},IF({1,0,0},INT((ROW(A:A)-1)/2),MOD(ROW(A:A)-1,2)),IMPORTXML("http://example.com","//td/a | //td/a/#href"))),"select min(Col3) where Col3 <> '' group by Col1 pivot Col2",0),"offset 1",0))
Replace the contents of IMPORTXML with your data and query and see if that works for you. I
Apparently, this attempts to invoke the IMPORTXML function only once. It's a solution for now, at least.
Here's the full thread.
This is the best solution (NOT MINE) posted in the comments below. To be honest, I'm not sure how it works. Perhaps #Pandora, the original poster, could provide an explanation.
=ArrayFormula(iferror(hlookup(1,{1;ARRAY},(row(A:A)+1)*2-transpose(sort(row(A1:A2)+0,1,0)))))
This is a very ugly solution and doesn't even explain how it works. At least I couldn't get it to work due to multiple errors, like i.e. to much parameters for IF (because an array is used). A shorter solution can be found here =ArrayFormula(iferror(hlookup(1,{1;ARRAY},(row(A:A)+1)*2-transpose(sort(row(A1:A2)+0,1,0))))) "ARRAY" can be replaced with IMPORTXML-Function. This function can be used for as much XPATHS one wants. – Pandora Mar 7 '19 at 15:51
In particular, it would be good to know how to modify the formula to accommodate more columns.

Resources