This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Wolfram Research, Inc.

Advanced Topic: Finding and Manipulating FilesExporting Graphics and Sounds

1.11.3 Importing and Exporting Data

Importing and exporting tabular data.

This exports an array of numbers to the file out.dat.

In[1]:= Export["out.dat", {{5.7, 4.3}, {-1.2, 7.8}}]


Here are the contents of the file out.dat.

In[2]:= !!out.dat

"5.7 4.3

-1.2 7.8"

This imports the contents of out.dat as a table of data.

In[3]:= Import["out.dat", "Table"]


Import["file", "Table"] will handle many kinds of tabular data, automatically deducing the details of the format whenever possible. Export["file", list, "Table"] writes out data separated by spaces, with numbers given in C or Fortran-like form, as in 2.3E5 and so on.

Importing and exporting general data.

Import and Export can handle not only tabular data, but also data corresponding to graphics, sounds and even whole documents. Import and Export can often deduce the appropriate format for data simply by looking at the extension of the file name for the file in which the data is being stored. Sections 2.9.19 and 2.11.7 discuss in more detail how Import and Export work. Note that you can also use Import and Export to manipulate raw files of binary data.

This imports a graphic in JPEG format.

In[4]:= Import["turtle.jpg"]


This displays the graphic.

In[5]:= Show[%]


Finding the complete list of supported import and export formats.

Advanced Topic: Finding and Manipulating FilesExporting Graphics and Sounds