# How to plot data from table dynamically, without knowing how many columns are there?

I'm trying to read coordinates at certain times of Planets and Plot the orbit into a graph. For this example I'm doing this for eight planets, some coordinates from a table of some timesteps of the first Planet are shown below for example.

Like this it works perfectly, but it just works for eight planets and what this program should do, is to read and plot the data without knowing how many Planets are there.

Is there a way to count the colums of the table and plot each column without knowing how many are there?

I'm stuck with that problem for quite a time now and would be very thankful for some advice. Thank you!

Quit

In[78]:= data = Import["Data.out", "CSV"];

In[79]:= TableForm[%78]

Out[79]//TableForm= Out[79]

In[119]:= Graphics3D[{Point[data[[All, {1, 2, 3}]]],
Point[data[[All, {4, 5, 6}]]], Point[data[[All, {7, 8, 9}]]],
Point[data[[All, {10, 11, 12}]]], Point[data[[All, {13, 14, 15}]]],
Point[data[[All, {16, 17, 18}]]], Point[data[[All, {19, 20, 21}]]],
Point[data[[All, {22, 23, 24}]]]}, Axes -> True,
AxesStyle -> {Red, Green, Blue}, AxesLabel -> {"x", "y", "z"},
Background -> LightBlue, ImageSize -> Large]

Out[119]= \!\(\*
Graphics3DBox[{
Point3DBox[{{0, 0, 0}, {0.0579994, 0.000421456, 0.030788}, {
0.231862, 0.00337144, 0.123077}, {0.521528, 0.0113774,
0.276824}, {0.9269, 0.0269648, 0.491961}, {1.44784, 0.0526558,
0.768391}, {2.08417, 0.0909683, 1.10599}, {2.83567, 0.144415,
1.5046}, {3.70209, 0.215503, 1.96405}, {4.68313, 0.306731,
2.48412}, {5.77847, 0.42059, 3.06459}, {6.98771, 0.559562,
3.70519}, {8.31047, 0.726116, 4.40564}, {9.74628, 0.922714,
5.1656}, {11.2947, 1.1518, 5.98476}, {12.9551, 1.41581,
6.86272}, {14.727, 1.71717, 7.7991}, {16.6098, 2.05827,
8.79348}, {18.6028, 2.4415, 9.84541}, {20.7054, 2.86924,
10.9544}, {22.9169, 3.34384, 12.12}, {25.2365, 3.86762,
13.3416}, {27.6634, 4.4429, 14.6187}, {30.1968, 5.07197,
15.9507}, {32.8359, 5.75709, 17.3371}, {35.5797, 6.50052,
18.7771}, {38.4274, 7.30447, 20.2702}, {41.378, 8.17115,
21.8157}, {44.4304, 9.10271, 23.4128}, {47.5838, 10.1013,
25.0609}, {50.837, 11.169, 26.7592}, {54.1889, 12.308,
28.5069}, {57.6384, 13.5203, 30.3034}, {61.1845, 14.8079,
32.1476}, {64.8257, 16.1728, 34.0389}, {68.5611, 17.617,
35.9764}, {72.3893, 19.1424, 37.9592}, {76.3091, 20.751,
39.9863}, {80.3192, 22.4445, 42.057}, {84.4182, 24.2248,
44.1702}, {88.6048, 26.0938, 46.3251}, {92.8776, 28.0531,
48.5206}, {97.2353, 30.1045, 50.7557}, {101.676, 32.2497,
53.0295}, {106.199, 34.4903, 55.341}, {110.803, 36.828,
57.689}, {115.485, 39.2642, 60.0726}, {120.245, 41.8006,
62.4906}, {125.081, 44.4386, 64.942}, {129.991, 47.1796,
67.4257}, {134.974, 50.0252, 69.9406}, {140.028, 52.9765,
72.4855}, {145.151, 56.035, 75.0594}, {150.343, 59.202,
77.6609}, {155.601, 62.4786, 80.2891}, {160.923, 65.8661,
82.9427}

• Graphics3D[Point /@ Transpose[Partition[#, 3] & /@ Transpose[data]], Axes -> True, AxesStyle -> {Red, Green, Blue}, AxesLabel -> {"x", "y", "z"}, Background -> LightBlue, ImageSize -> Large]? – kglr Apr 5 '18 at 10:50
• See kglr's comment. I would recommend the following documentation topics to understand the functions and concepts used: ref/Map, ref/Function, ref/Partition and ref/Transpose. – Theo Tiger Apr 5 '18 at 10:55
• Thank you for the quick answer! It says "Coordinate { , , } should be a triple of numbers or a scaled form" I think that I should not transpose it. What you can see on the bottom of my example is the result of "Point[data[[All, {1, 2, 3}]]]" and this are the first three columns of the table. Do you know how to get three columns at a time like that till the last column? – Ulrich Penitz Apr 5 '18 at 11:03
• The idea behind kglr's code is to first transpose the data so that columns become level 1 in the list, then split the list into partitions of 3 using Partition, then transpose it back. Your error message indicates that there are empty (non-numeric) cells imported which cannot be plotted. You may want to filter the numeric values with Cases first. Takes a little longer to explain, however, and some example data might come in handy. – Theo Tiger Apr 5 '18 at 13:11
• I got it, there was just one Transpose too much. Thank you kglr!! Graphics3D[Point /@ Transpose[Partition[#, 3] & /@ data], Axes -> True, AxesStyle -> {Red, Green, Blue}, AxesLabel -> {"x", "y", "z"}, Background -> LightBlue, ImageSize -> Large] – Ulrich Penitz Apr 5 '18 at 15:46