I'm trying to import a matrix from Excel to Mathematica. My code is:

Import["desktop/stproj.xls", "xls", data, 1]

The output is some weird stuff about population counts and not at all related to what's in the excel file. Can anyone help me with importing this?

  • $\begingroup$ Marty Cohen's answer below is sage advice--I do the same when I'm trying to import data from a spreadsheet. If that's not an option, then you should probably make your spreadsheet accessible to the SE community. One thing I'll mention is that your import command should start with a capital letter (as do all built-in Mathematica functions). $\endgroup$
    – Cassini
    Mar 24, 2012 at 4:29
  • 1
    $\begingroup$ @David, I think = in the original question is important in relation to the "weird stuff about population counts...` OP is puzzled about. $\endgroup$
    – kglr
    Mar 24, 2012 at 4:52
  • 1
    $\begingroup$ @R.M my comment about the previous edit was unintentionally directed to the David Skulsky. It was intended for David, but I could not figure out how to ping David. I think editing out = in the original version destroys the whole question. $\endgroup$
    – kglr
    Mar 24, 2012 at 7:04

2 Answers 2


With syntax errors fixed:

  Import[" appropriate path /Desktop/stproj.xls", "xls", "Data", 1]

should import the file.

Regarding population counts you are getting, the = sign at the beginning of an input cell invokes Wolfram Alpha query which allows free-form input (hence you get no syntax error warnings). Interestingly, Wolfram Alpha interprets the query somehow and returns:

enter image description here

If you click the red + button on the top right to get the full results, you see why W|A returns with this result:

enter image description here


Whenever I want to import Excel data, I first save the Excel file as a csv file with either commas or tabs as the separators. The result is a pure text file that can be readily imported and manipulated.

  • 5
    $\begingroup$ Mathematica imports both .xls and .xlsx files so this is not necessary. $\endgroup$
    – Verbeia
    Mar 24, 2012 at 6:25
  • 3
    $\begingroup$ Importing from a csv file is faster than other formats in general. $\endgroup$ Jan 9, 2013 at 17:11

Your Answer

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