1
$\begingroup$

I have a .dat file with two columns (one for x axis and one for y axis). is it possible to import the file in order to make a list plot out of it, or do I have to format it into list format to plot it with Mathematica.

$\endgroup$
3
  • $\begingroup$ reference.wolfram.com/language/guide/ImportingAndExporting.html $\endgroup$
    – mattiav27
    Dec 23, 2016 at 17:43
  • $\begingroup$ The import format you need to use is "Table", although if the file extension is ".dat" then that is implied. All you need is ListPlot @ Import @ "myfile.dat" $\endgroup$
    – Jason B.
    Dec 23, 2016 at 17:44
  • 2
    $\begingroup$ For others who may encounter this question, .dat is by no means a standard file format extension. Mathematica by default takes .dat to mean Table format which is correct for this example. The extension .dat really is so generic it could be about anything. $\endgroup$
    – george2079
    Dec 23, 2016 at 18:47

1 Answer 1

2
$\begingroup$
Data = Import["C:\\tcdata\\myfile.dat", "Table"][[All, {1, 2}]]

ListPlot[Data]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.