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

GZIP (.gz)

MIME type: application/x-gzip
GZIP compression method and file format.
General-purpose lossless compression method.
Commonly used for archiving data and for exchanging files on the internet.
Often used in combination with TAR.
Popular on Unix systems.
The GZIP file format is described in the internet standard recommendation RFC 1952.
Binary format.
Stores a single file.
  • Import and Export support the GZIP file format specification Version 4.3.
  • Import uncompresses and imports a GZIP-compressed archive.
  • Export exports any expression expr to a GZIP-compressed file whose format is implied by the file name extension .ext.
  • Import uncompresses file.gz and imports file, automatically inferring the format from the file contents.
  • Import uncompresses a GZIP file and imports it as .
  • Since Mathematica can automatically recognize all common file-compression and archive formats, it is never necessary to specify as a format in the second argument of Import.
  • Import imports the specified element from file.
  • Import imports multiple elements.
  • The import format can be explicitly specified with Import.
  • Export creates a GZIP-compressed .ext file by treating expr as specifying element elem.
  • Export treats each as specifying the corresponding .
  • Export exports expr with the specified option elements taken to have the specified values.
  • The export format and GZIP compression method can be explicitly specified with Export.
  • See the reference pages for full general information on Import and Export.
  • The GZIP format itself does not support Import or Export elements.
  • Import elements of the GZIP-compressed file:
"Elements" elements and options available in this file
"Rules"full rules for each element and option
"Options"rules for options, properties, and settings
  • Import returns the names of elements available in , effectively unpacking the compressed archive before importing the enclosed file.
"CompressionLevel"AutomaticGZIP compression strength, given as a number in the range 0 to 1
  • The setting corresponds to the strongest available compression, resulting in the smallest possible file size.
Export a string to a GZIP-compressed text file:
Convert the previous output back to a Mathematica string:
This exports graphics to a GZIP-compressed JPEG file:
This gives the available Import elements of the JPEG file:
When importing any element from a .gz file, Mathematica automatically uncompresses it:
Export a string to a GZIP-compressed text file:
In[1]:=
Click for copyable input
Out[1]=
Convert the previous output back to a Mathematica string:
In[2]:=
Click for copyable input
Out[2]=
 
This exports graphics to a GZIP-compressed JPEG file:
In[1]:=
Click for copyable input
Out[1]=
This gives the available Import elements of the JPEG file:
In[2]:=
Click for copyable input
Out[2]=
When importing any element from a .gz file, Mathematica automatically uncompresses it:
In[3]:=
Click for copyable input
Out[3]=