# Read a file into a list of vectors [closed]

I have file structured as (Axis 1) (Axis 2) Data.
As an example:

1.2E-003 -0.500        0.0000000000000000
1.2E-003 -0.493       1.53468784818295775E-004
1.2E-003 -0.487       5.89210645476378352E-004
1.2E-003 -0.481       1.23713800962565101E-003
1.2E-003 -0.475       1.99285240196946144E-003

2.8E-003 -0.500        0.0000000000000000
2.8E-003 -0.493       1.65202052327590321E-004
2.8E-003 -0.487       6.34230407238311057E-004
2.8E-003 -0.481       1.33156043724947304E-003
2.8E-003 -0.475       2.14469618088317755E-003


In other words:

• Each line has 3 real values
• The data is divided in blocks separated by a blank line.
• The size of each block is between 200 and 3000 (this size is unknown prior to reading the file, but I could write a shell script to extract and store this information somewhere if that makes things easier).
• The first value is the same for the entire block.
• There are exactly 1000 blocks.

I would like Mathematica to open this file and store this information inside a variable. This variable would be a list of vectors.

In this list, each element (a vector) corresponds to 1 block, and this vector contains the data from the third column (all other data is discarded).

In this example, the variable should be a list of 2 vectors:

{{ 0.0000000000000000 , 1.53468784818295775E-004 , 5.89210645476378352E-004 , 1.23713800962565101E-003 , 1.99285240196946144E-003 },
{ 0.0000000000000000 , 1.65202052327590321E-004 , 6.34230407238311057E-004 , 1.33156043724947304E-003 , 2.14469618088317755E-003 }}


Is this easy to do?

-

## closed as too localized by Ajasja, rcollyer, Yves Klett, acl, m_goldbergMar 4 '13 at 19:14

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Yes, please have a look at Import. – b.gatessucks Mar 4 '13 at 13:07

ReadList["file.dat", {Number, Number, Number}] ~SplitBy~ First

SplitBy[Import["file.dat", "Table"], # === {} &] ~DeleteCases~ {{}}

You can then use Part to get what you want. – Mr.Wizard Mar 4 '13 at 16:05