[ SciPy v1.12.0 Manual  ](../../index.html)

  * [ Installing ](https://scipy.org/install/)
  * [ User Guide ](../../tutorial/index.html)
  * [ API reference ](../index.html)
  * [ Building from source ](../../building/index.html)
  * [ Development ](../../dev/index.html)
  * [ Release notes ](../../release.html)

__ __ __

1.12.0

  * [ __ GitHub  ](https://github.com/scipy/scipy "GitHub")
  * [ __ Twitter  ](https://twitter.com/SciPy_team "Twitter")

__

  * [ scipy ](../main_namespace.html)
  * [ scipy.cluster ](../cluster.html)
  * [ scipy.constants ](../constants.html)
  * [ scipy.datasets ](../datasets.html)
  * [ scipy.fft ](../fft.html)
  * [ scipy.fftpack ](../fftpack.html)
  * [ scipy.integrate ](../integrate.html)
  * [ scipy.interpolate ](../interpolate.html)
  * [ scipy.io ](../io.html)
  * [ scipy.linalg ](../linalg.html)
  * [ scipy.misc ](../misc.html)
  * [ scipy.ndimage ](../ndimage.html)
  * [ scipy.odr ](../odr.html)
  * [ scipy.optimize ](../optimize.html)
  * [ scipy.signal ](../signal.html)
  * [ scipy.sparse ](../sparse.html)
  * [ scipy.spatial ](../spatial.html)
  * [ scipy.special ](../special.html)
  * [ scipy.stats ](../stats.html)

__ On this page

  * ` readsav  `

#  scipy.io.readsav  #

scipy.io.  readsav  (  _ file_name  _ , _ idict  =  None  _ , _ python_dict  =
False  _ , _ uncompressed_file_name  =  None  _ , _ verbose  =  False  _ )  [
[source]
](https://github.com/scipy/scipy/blob/v1.12.0/scipy/io/_idl.py#L677-L918) #

    

Read an IDL .sav file.

Parameters  :

    

**file_name** str

    

Name of the IDL save file.

**idict** dict, optional

    

Dictionary in which to insert .sav file variables.

**python_dict** bool, optional

    

By default, the object return is not a Python dictionary, but a case-
insensitive dictionary with item, attribute, and call access to variables. To
get a standard Python dictionary, set this option to True.

**uncompressed_file_name** str, optional

    

This option only has an effect for .sav files written with the /compress
option. If a file name is specified, compressed .sav files are uncompressed to
this file. Otherwise, readsav will use the [ ` tempfile  `
](https://docs.python.org/3/library/tempfile.html#module-tempfile "\(in Python
v3.12\)") module to determine a temporary filename automatically, and will
remove the temporary file upon successfully reading it in.

**verbose** bool, optional

    

Whether to print out information about the save file, including the records
read, and available variables.

Returns  :

    

**idl_dict** AttrDict or dict

    

If _python_dict_ is set to False (default), this function returns a case-
insensitive dictionary with item, attribute, and call access to variables. If
_python_dict_ is set to True, this function returns a Python dictionary with
all variable names in lowercase. If _idict_ was specified, then variables are
written to the dictionary specified, and the updated dictionary is returned.

Examples

    
    
    >>> from os.path import dirname, join as pjoin
    >>> import scipy.io as sio
    >>> from scipy.io import readsav
    

Get the filename for an example .sav file from the tests/data directory.

    
    
    >>> data_dir = pjoin(dirname(sio.__file__), 'tests', 'data')
    >>> sav_fname = pjoin(data_dir, 'array_float32_1d.sav')
    

Load the .sav file contents.

    
    
    >>> sav_data = readsav(sav_fname)
    

Get keys of the .sav file contents.

    
    
    >>> print(sav_data.keys())
    dict_keys(['array1d'])
    

Access a content with a key.

    
    
    >>> print(sav_data['array1d'])
    [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
     0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
     0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
     0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
     0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
     0. 0. 0.]