Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am importing data from Excel and plotting it with DateListPlot. My code is

DateListPlot[{
  Join @@ Import[""][[1 ;;, 3 ;;]][[All, All, 2 ;; 3]], 
  Join @@ Import[""][[1 ;;, 3 ;;]][[All, All, 4 ;; 5]]}, 
  Joined -> True, 
  FrameTicks -> All]

But my problem is this works for just for the first sheet (year 2013) of the many in the same file. Sheet 2 is for Year 2012 and has the same format, and so forth. I want to get all the sheets for all the years; they are continuations of each other. Could you help me to figure out what code will do this?

share|improve this question
2  
offtop: 1;; = ;; = All –  Kuba Jun 21 '13 at 10:42
    
@Kuba thanks can you see my coding skills?!!!! –  Alex Jun 21 '13 at 10:47
add comment

1 Answer

up vote 2 down vote accepted

This might work:

Import["test.xls", "Sheets"]

{Sheet1, Sheet2}

data1 = Import["test.xls", {"Sheets", "Sheet1"}];
data2 = Import["test.xls", {"Sheets", "Sheet2"}];
all = Sort[Join[data1, data2]];
DateListPlot[all, Joined -> True]

But I haven't got Excel here so I can't test it.

Edit

With lots of sheets:

sheets = Import["test.xls", "Sheets"]
data  =  Import["test.xls", {"Sheets", # }] & /@ sheets

and see how the data looks then.

share|improve this answer
    
thanks but what if I have 50 sheets?Please pay attention to my required format of [[1 ;;, 3 ;;]][[All, All, 2 ;; 3]], [[1 ;;, 3 ;;]][[All, All, 4 ;; 5]] –  Alex Jun 21 '13 at 10:37
1  
@Alex No idea what all that means... :) But once you've imported the data, just select the bits you want - that should be basic list-manipulation stuff. –  cormullion Jun 21 '13 at 10:58
    
It fails to import data what could be wrong? –  Alex Jun 21 '13 at 11:18
1  
I'm sorry, I'm not a doctor... :/ –  cormullion Jun 21 '13 at 11:28
    
I am recovered :D thanks –  Alex Jun 21 '13 at 12:13
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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