I have an Excel spreadsheet column with hundreds of company names on it. I need to find the address (or just city if that's easier)

The operation for this is simple in wolfram alpha. i.e. typing "Target headquarters" returns "1000 Nicollet Mall Minneapolis Minnesota 55403"

How do I use mathematica or the wolfram cloud programming language to automate this? I found this similar question: Use the value of a cell in a table as the argument to a function but can't get it to work for my problem.

I'm pretty good with excel,so I can turn the spreadsheet column into a list or anything if needed.

Thanks for any and all help!

  • 1
    $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Jul 13 '15 at 17:24
companies = 
  WolframAlpha["Top ten companies", {{"Result", 1}, "ComputableData"},
     PodStates -> {"Result__More"}][[All, 2]];

table = {#, 
     WolframAlpha[# <> 
       " headquarters street address", {{"Location:FinancialData", 1},
      PodStates ->
       {"Location:FinancialData__Show street address"}]} & /@

table // Grid[#, Alignment -> Left] &

enter image description here

  • $\begingroup$ Bob thanks for responding. I started by just copying your code and then planned on figuring out how to swap out your "companies" list with my own. However, when I ran your code I get far from your neat table. Mine just returns a lot of errors. Does it matter that I'm using the wolfram cloud programming and not local mathematica? $\endgroup$ – singmotor Jul 13 '15 at 18:01
  • 1
    $\begingroup$ I've never used Wolfram cloud programming so cannot comment on its use. $\endgroup$ – Bob Hanlon Jul 13 '15 at 18:04
  • $\begingroup$ Bob, I got regular mathematica and it works, so that's great! I was wondering if you could explain your code a bit more though. How do I swap in my company list? Also, what are PodStates, and why do you use "FinancialData" as opposed to regular Location? $\endgroup$ – singmotor Jul 14 '15 at 13:50
  • $\begingroup$ Just define companies with your list: companies = <your list here>. Start with the basic query (e.g., WolframAlpha["Apple headquarters street address"]), in the returned Location pod click the button Show street address, click the + button in that pod, and select Computable data. The specific query is pasted into the workbook. I just used this as a template. $\endgroup$ – Bob Hanlon Jul 14 '15 at 14:07
  • $\begingroup$ @Acoustic77 - using Mma 10.1 running on Mac OS 10.10.4, I get three pods: Input interpretation, Result (lat, long in dms with button for Show decimal), and Location (city, state, zip, country, map, and button to Show street address). $\endgroup$ – Bob Hanlon Jul 14 '15 at 14:34
CompanyData[Entity["Company", "Your company here"], "City"]

CompanyData[Entity["Company", "Mars"], "City"] -> McLean
  • $\begingroup$ Lol, try CompanyData[Entity["Company", "Wolfram Research"], "City"]. $\endgroup$ – Michael E2 Jul 13 '15 at 17:27
  • $\begingroup$ I tried many company names in place of Mars and none worked other than Mars. (even big ones such as apple, google, etc). Also, my goal is to automate the lookup of a spreadsheet with hundreds, so I need a loop of sorts. Thank you for your response though! $\endgroup$ – singmotor Jul 14 '15 at 14:31

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.