Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .dat file from FORTRAN output and I am trying to plot the results. The dat file is a series of rows with the row number as the first column. Now, every other row is empty, that may be problematic. I am trying to plot the second column vs the third column (not the row nr that is, but the actual data). I can´t get the second and third column into an individual array. This is what I am trying to do

data = Import["C:\\Users....file.dat","Table"]
1 1 0

2 0.999398 -0.000086244

3 0.997592 -0.000344186

4 0.994588 -0.000772091

Every other row in the table is empty, that is:

{}, {1, 1., 0.}, {}, {2, 0.999398, -0.000086244}, {},

I am trying to do

x = data[[ALL, 2]]

But I receive an error informing me that ALL is not an integer

Part::pspec: Part specification ALL is neither an integer nor a list of integers

How can I take all the values in the column 2 and 3 and store them in an individual arrays. If the empty rows will be problematic, how can I get rid of them?

share|improve this question
Have a look at "IgnoreEmptyLines" here – Ajasja Feb 8 '13 at 19:26
All right, thanks guys, I got it. – l3win Feb 8 '13 at 19:38
@l3win make sure to upvote and accept the answer if it helped you. – Ajasja Feb 8 '13 at 19:43
Check your spelling: It is All, not ALL – Thomas Feb 8 '13 at 20:11
Do you have spaces between the entries in each row? Fortran doesn't do that by default, I know. – Szabolcs Feb 8 '13 at 20:48

A few possibilities:

data = {{1, 2, 3}, {}, {4, 5, 6}, {}, {7, 8, 9}, {}}

And then any of these should work:

Cases[data, Except[{}]]

Select[data, # =!= {} &]

DeleteCases[data, {}]

data[[1 ;; -1 ;; 2]]
share|improve this answer

Your Answer


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.