UI Bootstrap typeahead sorting - angular-ui-bootstrap

I'm using the excellent 'typeahead' control from angular-ui-bootstrap (http://angular-ui.github.io/bootstrap/#/typeahead). My HTML looks like this:
<input type="text" ng-model="selected"
typeahead="location.name for location in cities
| filter:$viewValue
| limitTo:8" class="form-control"
placeholder="City" ng-model="citysearch">
My problem is how alternatives are sorted. I would like alternatives starting with the typed text to appear on top, but instead other alternatives which merely contain the typed text (sometimes) appear first. For example, consider the following available cities.
New York
London
Los Angeles
Washington
Stockholm
If I type 'S' I would expect Stockholm to appear first, but instead Los Angeles And Washington are first. (Probably because they come before Stockholm in the original array.)
Can I somehow configure this behavior in the typeahead control?
Thanks,
Daniel

Related

Limit the importxml to a defined span

Currently I am using a transpose and then another column to count the results and give me what I want. But because Tanaike is awesome and helped me on another section, I am trying to wrap my head around what he did and apply it to this.
Starting with this URL in A1,
https://www.zillow.com/homedetails/307-N-Rosedale-Ave-Tulsa-OK-74127/22151896_zpid/
This is the formula in A2:
=If($A$1:A="","",Transpose(importxml($A1:$A,"//span[#class='snl phone']")))
Based on the listing sometimes there are three phone numbers, sometimes four, and sometimes eight that get spread across as many columns as needed.
I am looking for the Property Owner phone number. This is the ELEMENT from the inspection.
<div class="info flat-star-ratings sig-col" id="yui_3_18_1_2_1506365934526_2361"> <span class="snl name notranslate">Property Owner</span> <span class="snl phone" id="yui_3_18_1_2_1506365934526_2360">(918) 740-1698 </span> </div>
So I tried this, and it comes up content is empty. I was thinking to look at the div class info flat, then within that the snl phone, and stop before the /end of span.
=importXML(B17,"//div[#class='info flat-star-ratings sig-col']//span[#class='snl phone']/#span")
What I really need is ONLY the property owner phone number with 95% or greater accuracy.
How about this modification of XPath query?
Modified XPath query :
=importxml(A1,"//div[#class='info flat-star-ratings sig-col']//span[#class='snl phone']")
Result :
If this is not data you want, I'm sorry.
Edit :
4th and 8th number are the same. Is my understanding correct? If it's no problem. Please put URL and a following formula to "A1" and "A2", respectively.
=QUERY(ARRAYFORMULA(IF(IMPORTXML(A1,"//div[#class='info flat-star-ratings sig-col']//span[#class='snl name notranslate']")="Property Owner",IMPORTXML(A1,"//div[#class='info flat-star-ratings sig-col']//span[#class='snl phone']"), "")),"Select * where Col1<>''")
Result :

Google sheets - How do I make a query that prints data from a dropdown box

I want to be able to pick a country from a dropdown box, which will then print the cities in the country as well as a string of numbers. Here is my google sheet:
https://docs.google.com/spreadsheets/d/1ypcJ72cE08f69djnaXE2urLIyk8o33E7oHoshDjkfCw/edit?usp=sharing
So for example, if I select India from my dropdown box, I want it to print:
Mumbai 646
New Delhi 264
Kolkata 346
But I want the cities and the numbers to be in different cells, just like how they are originally in C1:D4. How would I go about doing this?
In A12 of the sheet you shared I entered
=offset(A1,1 ,match(A9,A1:H1,0)-1, counta(A1:A4),2)
See if that works for you?

Using =IMPORTXML in Google Spreadsheets to extract a table by descriptions

From the website http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396 I am trying to extract just the text data such as, birth, death, bio, location, and the created by sections into different rows/columns. I want to be able to have a spreadsheet where I can input a FindAGrave URL and have it extract the above data for me. I read here Using =importXML in Google Docs that its possible to do it by descriptions. From there I learned to omit the Xpath tbody. That successfully got my import to work, but without using the descriptions. I'm sure if using descriptions would be more efficient or not. I just want to learn how other people would go about importing data from tables.
Thanks
Here is what I got so far. This will extract the Birth information and put in rows. One problem is that it adds an extra cell in between each data.
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//html/body/table/tr/td[3]/table/tr[4]/td[1]/table/tr/td/table/tr/td/table/tr[1]/td[2]")
Result
Dec. 2, 1882 Humphreys County Tennessee, USA
Update: I think I made some process along in the code. This is what I'm working with now.
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr'][1]//tr/td/table/tr/td/table/tr[1]/td[1]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[1]/td[2]/text()[1]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[1]/td[2]/text()[2]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[1]/td[2]/text()[3]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[1]/td[2]/text()[4]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr'][1]//tr/td/table/tr/td/table/tr[2]/td[1]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[2]/td[2]/text()[1]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[2]/td[2]/text()[2]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[2]/td[2]/text()[3]")
=IMPORTXML("http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396", "//*[#class='gr']//tr/td/table/tr/td/table/tr[2]/td[2]/text()[4]")
Results:
Birth:
Nov. 8, 1948
Benton
Saline County
Arkansas, USA
Death:
Jan. 6, 2006
Tulsa
Tulsa County
Oklahoma, USA
Is there a way to split this data up within the code?
The following formula
=IMPORTXML(
"http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396",
"//html/body/table/tr/td[3]/table/tr[4]/td[1]/table/tr/td/table/tr/td/table/tr[position()<=2]/td/text()"
)
returns
Birth:
Nov. 8, 1948
Benton
Saline County
Arkansas, USA
Death:
Jan. 6, 2006
Tulsa
Tulsa County
Oklahoma, USA
A shorter alternative,
=IMPORTXML(
"http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GScid=97961&GRid=22682396",
"//tr[4]/td[1]//tr[position()<=2]/td/text()"
)
returns the same result
You can get multiple fields by simplifying your xpaths - you can also add multiple into one single function call separating the xpaths with a | :
`=ARRAYFORMULA(TRIM(TRANSPOSE(IMPORTXML($A3,"//td[#align='left']/text()|//tr[6]/td/a|//tr[3]/td/text()[1]"))))`
The three xpaths used are:
//td[#align='left']/text()
//tr[6]/td/a
//tr[3]/td/text()[1]

Google search place api, places not found

Somes places are not found from google api,
It used to return results before the last update but it does not anymore.
examples :
Pizza hut - france
Domino's pizza - france
In & out burger - los angeles
etc..
https://maps.googleapis.com/maps/api/place/search/json?sensor=false&location=34.029900,-118.255463&radius=5000&key=API_KEY&name=In-N-Out%20Burger
https://maps.googleapis.com/maps/api/place/search/json?sensor=false&location=48.847194,2.408152&radius=5000&key=API_KEY&name=Pizza%20Hut
https://maps.googleapis.com/maps/api/place/search/json?sensor=false&location=48.847194,2.408152&radius=5000&key=API_KEY&name=Domino's%20Pizza
Do you know why ?
Had the same issue but solved it this way:
For spaces: have to enclose the whole name in double quotes: %22name%20with%20spaces%22
For quotes: have to encode them as a space: Domino%20s
I tried it with your pizza hut example and got results back with my key

Parsing text content in ColdFusion

I am attempting to parse text from a <cfoutput query="...">. I am interested in finding the number of times every word in the text is displayed. For example:
"My name is Bob and I like to Bob".
should result in
Bob - 2
Name - 1
etc, etc, etc.
I take my <cfoutput> from a twitter RSS feed. Here is my code:
<blink>
<cfset feedurl="http://twitter.com/statuses/user_timeline/47847839.rss" />
<cftry>
<cffeed source="#feedurl#" properties="feedmeta" query="feeditems" />
<cfcatch></cfcatch>
</cftry>
<ol>
<cfoutput query="feeditems">
#content# #id# <br><br>
</cfoutput>
</ol>
</blink>
I output a pretty great ordered list, but I can't figure out for the life of me how to parse the content and list how many times each word is used.
Thanks for any help you can provide, I am new to these forums!
You can find a solution here:
http://www.coldfusionjedi.com/index.cfm/2007/8/2/Counting-Word-Instances-in-a-String
Basically, split the string up using regex and then loop over the results. There are some darn good comments here as well.

Resources