How to | Import and Export File Elements

Sometimes you may want to work with a specific part of a file instead of all of it. When bringing a file into the Wolfram Language, you can elect to import just individual parts of the file, which are called elements. The Wolfram Language's ability to import and export elements of files gives you greater control over the information being exchanged while simultaneously saving time and memory.

Begin by importing an image from the Wolfram Language documentation directory ExampleData:

In[1]:=
Click for copyable input
Out[1]=

Use as the second argument in Import to view the elements of the image that are available for import:

In[2]:=
Click for copyable input
Out[2]=

Get the pixel size of the image:

In[3]:=
Click for copyable input
Out[3]=

Import the complete of the image and set it to the variable . Since is large and you do not need to view all of it, the output is suppressed here with a semicolon:

In[4]:=
Click for copyable input

You can now analyze the image data, for example by using ListPlot3D:

In[5]:=
Click for copyable input
Out[5]=
    

After importing, you can then export elements to control exactly what is exported. This gives you a great deal of extensibility when working with data in different files and formats.

Import the first sheet of data from the spreadsheets and from the Wolfram Language documentation directory ExampleData:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input

Export these to separate sheets in a single spreadsheet file:

In[3]:=
Click for copyable input
Out[3]=

The specific Import and Export elements that can be used depend on the file formats you are working with. For more information, see the documentation pages for the formats. There is also some additional information in How to: Import and Export.