# How to visualize a .dat file in mathematica?

I have a dat file which contains a large amount of points. I can able to view the values from the dat file in mathematica but I don't make a plot column 3 vs 2 graph from the dat file. Can anyone help me to plot this graph. Here is the view of my dat file:

• 1. Import it. 2. Wrangle the data, that is, get it in some format one of the *Plot* functions can handle. 3. Plot it.
– ktm
Nov 13 '18 at 3:25
• What have you tried so far?
– ktm
Nov 13 '18 at 3:25
• Well, I think it about more data re-structure than data visualization. Nov 13 '18 at 5:10
• Please provide a small data (text) sample in the post, which will help testing and providing solutions that much easier. Take a look at Import and related functions as well in the online help. Nov 13 '18 at 7:52

Let's create a fake dataset and save it.

data0 = Table[{x, Sin[x], Cos[x]}, {x, 0.0, 2.0 Pi, Pi/5}];
Export["data.dat", data0]


This is how you export data to a file.

Now the data.dat has 3 column. To make it look like your file, I open it in a text editor and add something

# something
0.0000000000000000  0.000000000000000   1.00000000000000
0.6283185307179586  0.5877852522924731  0.8090169943749475
1.2566370614359172  0.9510565162951535  0.30901699437494745
1.8849555921538759  0.9510565162951536  -0.30901699437494734
2.5132741228718345  0.5877852522924732  -0.8090169943749473
3.141592653589793   1.2246467991473532e-16  -1.000000000
3.7699111843077517  -0.587785252292473  -0.8090169943749476
4.39822971502571    -0.9510565162951535 -0.30901699437494756
5.026548245743669   -0.9510565162951536 0.30901699437494723
5.654866776461628   -0.5877852522924734 0.8090169943749473
6.283185307179586   -2.4492935982947064e-16 1.0000000000000000

1. Import data
data = Import["data.dat"];

1. Exclude the first line
data1 = data[[2 ;; -1]];


It means take the data from 2nd line to last line.

1. Plot
ListLinePlot[data1[[All, {1, 2}]]]


plot 2nd column against 1st column ({1,2})

ListLinePlot[data1[[All, {3, 2}]]]


plot 2nd column against 3rd column ({3,2}).

• data[[2;;]] also works instead of data[[2 ;; -1]]. Nov 13 '18 at 13:04
• Or Rest[data] also would work if preferred. Nov 13 '18 at 13:14
• It's working!! Thanks a lot for your kind help. Nov 15 '18 at 12:48