|
Import
Import["file.ext"] imports data from a file, assuming that it is in the format indicated by the file extension ext, and converts it to a Mathematica expression.
Import["file", "format"] imports data in the specified format from a file.
Import attempts to give a Mathematica expression whose meaning is as close as possible to the data in the external file.
Import can handle numerical and textual data, graphics, sounds, material from notebooks, and general expressions in various formats.
The following basic formats are supported for textual and tabular data:

"Text" and "UnicodeText" return single Mathematica strings.
"Lines" and "Words" return lists of Mathematica strings.
"List" returns a list of Mathematica numbers or strings.
"Table", "CSV" and "TSV" return a list of lists of Mathematica numbers or strings.
In "List", "Table", "CSV" and "TSV" formats, numbers can be read in C or Fortran-like "E" notation.
Numbers without explicit decimal points are returned as exact integers.
In "Table" format, columns can be separated by spaces or tabs.
In "Words" format, words can be separated by any form of white space.
In "CSV" format, columns are taken to be separated by commas, unless other settings are specified using ConversionOptions.
Import["file.txt"] uses "Text" format.
Import["file.dat"] uses "Table" format.
Import["file.csv"] uses "CSV" format.
The following additional formats are also supported for numerical data:

When appropriate, numerical data is imported as SparseArray objects.
The following format yields a list of expressions suitable for input to NMinimize:

Two-dimensional graphics formats are imported as Graphics objects; sound formats are imported as Sound objects.
Animated graphics are imported as lists of Graphics objects.
The following formats yield expressions of the form Graphics[data, opts]:

The following formats yield expressions of the form Graphics[Raster[data], opts]:


Imported raster data normally consists of integers; ColorFunction is often used to specify a color map.
The following formats return objects of the form Graphics3D[data, opts]:

The following formats yield expressions of the form Sound[SampledSoundList[data, r]]:

The following gives a notebook expression Notebook[... ] from a Mathematica notebook file:

The following XML formats give various types of expressions:

With format "MathML", MathML presentation elements are if possible imported as mathematical expressions using TraditionalForm interpretation rules. Otherwise, they are imported as box expressions.
With format "SymbolicXML", XML data of any document type is imported as a SymbolicXML expression.
With format "XML", Import will recognize MathML, NotebookML, and ExpressionML and interpret them accordingly. Other XML will be imported as SymbolicXML.
The following formats can be used for general expressions:

The following general options can be given:

Possible formats accepted by Import are given in the list $ImportFormats.
Import["!prog", "format"] imports data from a pipe.
See Section 1.11.3, Section 2.10.20 and Section 2.12.7.
See also: Export, ImportString, $ImportFormats, ReadList.
New in Version 4; modified in 5.0.
Additional Information
|