5
$\begingroup$

I have an excel file with about 40 cities listed. I would like to compare the cost of living for each one. I have seen the sample "relocation calculator" given by the input:

WolframAlpha["moving from St Louis to San Francisco salary $42,500", 
 IncludePods -> "Input", AppearanceElements -> {"Pods"}, 
 TimeConstraint -> {30, Automatic, Automatic, Automatic}, 
 PodStates -> {"PriceComparisons__Show prices", 
   "EquivalentSalary__Show history"}]

This output is nice but I would really like to have this for several cities and the output be formatted in rows and columns for my spreadsheet.

I have no idea how to go about this...

$\endgroup$
5
$\begingroup$

As an example

cities = EntityValue[CountryData["UnitedStates", "LargestCities"], 
   "Name"];
first = First@cities
rest = Rest@cities;
data = WolframAlpha[
     StringJoin["moving from ", first, " to ", #, 
      " $42,500"], {{"PriceComparisons", 1}, "ComputableData"}, 
     PodStates -> {"PriceComparisons__Show prices", 
       "PriceComparisons__More"}] & /@ Take[rest, 5];
goodies = data[[1, 2 ;;, 1]];
TableForm[Transpose@Join[{data[[1, 2 ;;, 2]]}, data[[All, 2 ;;, 3]]], 
 TableHeadings -> {goodies, Take[cities, 6]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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