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 txt file with space-delimited x, y, z coordinates of several points. The points are organized into groups of unequal size; the groups are delimited by skipping a line, like this:

2.3 3.4 5.5
2.4 3.3 5.6
2.5 3.5 5.6

1.2 4.3 3.3
0.7 4.0 3.5

-1.2 1.3 -0.7
-1.1 1.7 -0.5

I can't find a way to have Mathematica just import these then plot the points! I've tried searching a little bit but didn't find a similar question.

When plotting, it's not important to distinguish from which group each point came from. For example, I don't need different colours for each group or anything like that.

share|improve this question

I would use:

dat = ReadList["file.txt", Number, RecordLists -> True];

ListPointPlot3D[dat, PlotStyle -> PointSize[Large]]

Mathematica graphics

"file.txt" is of course the name (and if necessary the path) of your data file.

Thanks to the default option NullRecords -> False any extra lines are omitted from dat.

share|improve this answer
dat = Import["F:/data.txt", "Table"] /. {} -> Sequence[];
share|improve this answer
Even better is the option of import "IgnoreEmptyLines"->True – Ajasja Feb 27 '13 at 14:33
@Ajasja with that option this is a good method for data types that ReadList does not easily recognize. For regular numeric data it's bound to be slower than ReadList however. – Mr.Wizard Feb 27 '13 at 14:52

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.