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 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

2 Answers 2

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[];
ListPointPlot3D[dat]
share|improve this answer
1  
Even better is the option of import "IgnoreEmptyLines"->True –  Ajasja Feb 27 '13 at 14:33
1  
@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

 
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.