SciPy

Input and output (scipy.io)

SciPy has many modules, classes, and functions available to read data from and write data to a variety of file formats.

See also

numpy-reference.routines.io (in Numpy)

MATLAB® files

loadmat(file_name[, mdict, appendmat]) Load MATLAB file :Parameters: file_name : str Name of the mat file (do not need .mat extension if appendmat==True) Can also pass open file-like object.
savemat(file_name, mdict[, appendmat, ...]) Save a dictionary of names and arrays into a MATLAB-style .mat file.
whosmat(file_name[, appendmat]) List variables inside a MATLAB file :Parameters: file_name : str Name of the mat file (do not need .mat extension if appendmat==True) Can also pass open file-like object.

IDL® files

readsav(file_name[, idict, python_dict, ...]) Read an IDL .sav file :Parameters: file_name : str Name of the IDL save file.

Matrix Market files

mminfo(source) Queries the contents of the Matrix Market file ‘filename’ to extract size and storage information.
mmread(source) Reads the contents of a Matrix Market file ‘filename’ into a matrix.
mmwrite(target, a[, comment, field, precision]) Writes the sparse or dense array a to a Matrix Market formatted file.

Unformatted Fortran files

FortranFile(filename[, mode, header_dtype]) A file object for unformatted sequential files from Fortran code.

Wav sound files (scipy.io.wavfile)

read(filename[, mmap]) Return the sample rate (in samples/sec) and data from a WAV file :Parameters: filename : string or open file handle Input wav file.
write(filename, rate, data) Write a numpy array as a WAV file :Parameters: filename : string or open file handle Output wav file rate : int The sample rate (in samples/sec).

Arff files (scipy.io.arff)

loadarff(f) Read an arff file.

Netcdf (scipy.io.netcdf)

netcdf_file(filename[, mode, mmap, version]) A file object for NetCDF data.
netcdf_variable(data, typecode, size, shape, ...) A data object for the netcdf module.