Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I query Wolfram | Alpha with "city in orange county, california", it returns the first four results with a note that there are "42 total". I can then hit the "more" button until all 42 are visible.

I tried to get the same 42 results as computable data, in Mathematica 9.0.1.0, with this:

WolframAlpha["city in orange county, california", "ComputableData"]

which returns a list of the four items that initially come up when I ran the query on the Wolfram Alpha website:

{"Santa Ana", "Anaheim", "Irvine", "Huntington Beach", "Garden Grove"}

I've been sifting through online documentation and Google but haven't been able to figure out how to get all 42 cities. Any hints?

share|improve this question

1 Answer 1

up vote 5 down vote accepted
  • 1) Tap twice = on a new line
  • 2) After orange Spiky type: city in orange county, california
  • 3) Press button MORE till you get al cities
  • 4) Click little cross in the right top corner of the cities panel and choose from the sub-menu: Commutable Data

enter image description here

This is what you get (it may look cumbersome but the point is you don't have to type it - the code is auto-generated):

WolframAlpha["city in orange county, california", 
{{"Cities:USCountyData", 1}, "ComputableData"}, 
 PodStates -> {"Cities:USCountyData__More", 
   "Cities:USCountyData__More", "Cities:USCountyData__More", 
   "Cities:USCountyData__More"}]

{"Santa Ana", "Anaheim", "Irvine", "Huntington Beach", "Garden Grove", "Orange", "Fullerton", "Costa Mesa", "Mission Viejo", "Westminster", "Newport Beach", "Buena Park", "Lake Forest", "Tustin", "Yorba Linda", "Laguna Niguel", "San Clemente", "La Habra", "Fountain Valley", "Placentia", "Rancho Santa Margarita", "Cypress", "Aliso Viejo", "Brea", "Stanton", "Dana Point", "San Juan Capistrano", "Laguna Hills", "Seal Beach", "Tustin Foothills", "Laguna Beach", "Laguna Woods", "La Palma", "Coto de Caza", "Los Alamitos", "Foothill Ranch", "Rossmoor", "Portola Hills", "Villa Park", "Las Flores", "San Joaquin Hills", "Newport Coast"}

% // Length

42

---------- EDIT -------------

Thanks to the @ToddGayley nice comment we have a more compact version:

WolframAlpha["city in orange county, california", 
          {{"Cities:USCountyData", 1}, "ComputableData"}, 
            PodStates -> {"4@Cities:USCountyData__More"}]

Thanks Todd!

share|improve this answer
    
Fora slightly condensed form, you can group all four "More" requests into a single string: WolframAlpha["city in orange county, california", {{"Cities:USCountyData", 1}, "ComputableData"}, PodStates -> {"4@Cities:USCountyData__More"}] –  Todd Gayley Mar 7 '13 at 18:33
    
Thanks! So, if I'm going to be running different queries for different counties, I might as well use 99@ since I won't know how many "mores" are actually required in advance. Is it wrong of me to think of the WolframAlpha function as a glorified screen-scraper? –  Bezewy Mar 8 '13 at 1:39
    
@ToddGayley Thanks Todd! I updated the answer to include your code. –  Vitaliy Kaurov Mar 8 '13 at 4:20
    
@Bezewy: You're not wrong. This is nuts. Classic Wolfram to think this is usable or makes any kind of sense for users. –  raxacoricofallapatorius Mar 8 at 13:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.