MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Importing Several sheets from one Excel file into Mathematica

Hi Rosa,

> I have one excel file that contains three different 
> worksheets. When I import the data into Mathematica it only 
> imports the data from the first sheet, and it ignores the 
> rest of the sheets. Is there a way to tell Mathematica that 
> there is more than one sheet in this Excel file or do I have 
> to create separate files? The procedure I use to import the 
> data is the following:

For Mathematica 5.2 & Excel 2003 (XP), I can import data from an XLS file
which contains multiple sheets using Import["c:/Path/To/filename.xls"].
What version(s) are you using?
> Since I have several files of data to analyze, I create an 
> array with the file names and I import each file with a Loop 
> that assigns each file to a matrix (see below). I have no 
> problems importing the data to do the calculations, with the 
> exception for the above mentioned.  Any information that can 
> be provided will be greatly appreciated.
> Thank you in advance,
> Rosa.
> (***assign files to array***)
> data1={"test1.xls","test2.xls","test3.xls"};
> (***Loop to Import data files into separate matrices, and 
> arrange matrices for calculations***) Do[{
>     dat[k]=Import[data1[[k]]]; ...... ...
> },{k,1,Length[data1]}];

I don't see any real problems with the above code, especially given that it


	data = Import[#]& /@ data1;

should be equivalent, and may be quicker as Length@data1 increases.

Note that you can also 

	data1 = FileNames["*.xls"]

Rather than hardcoding your filenames.  Needless to say, you can filter
filenames as you like.



  • Prev by Date: Re: Graphics3D polygon face colors
  • Next by Date: Using pictures instead of symbols in an equation.
  • Previous by thread: Importing Several sheets from one Excel file into Mathematica
  • Next by thread: Re: Importing Several sheets from one Excel file into Mathematica