Re: Importing Several sheets from one Excel file into Mathematica

*To*: mathgroup at smc.vnet.net*Subject*: [mg65058] Re: [mg65011] Importing Several sheets from one Excel file into Mathematica*From*: "David Annetts" <davidannetts at aapt.net.au>*Date*: Sun, 12 Mar 2006 23:59:30 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

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 works. However, data = Import[#]& /@ data1; should be equivalent, and may be quicker as Length@data1 increases. Note that you can also SetDirectory["c:/My/Data/Directory"] data1 = FileNames["*.xls"] Rather than hardcoding your filenames. Needless to say, you can filter filenames as you like. Regards, Dave.