4
$\begingroup$

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?

$\endgroup$

1 Answer 1

6
$\begingroup$
  • 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!

$\endgroup$
4
  • $\begingroup$ 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"}] $\endgroup$ Commented Mar 7, 2013 at 18:33
  • $\begingroup$ 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? $\endgroup$
    – Bezewy
    Commented Mar 8, 2013 at 1:39
  • $\begingroup$ @ToddGayley Thanks Todd! I updated the answer to include your code. $\endgroup$ Commented Mar 8, 2013 at 4:20
  • $\begingroup$ @Bezewy: You're not wrong. This is nuts. Classic Wolfram to think this is usable or makes any kind of sense for users. $\endgroup$
    – orome
    Commented Mar 8, 2014 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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