Input and output (scipy.io)

See also

numpy-reference.routines.io (in Numpy)

MATLAB® files

loadmat(file_name, **kwargs[, mdict, appendmat]) Load MATLAB file
savemat(file_name, mdict[, appendmat, ...]) Save a dictionary of names and arrays into a MATLAB-style .mat file.

Matrix Market files

mminfo(source) Queries the contents of the Matrix Market file ‘filename’ to
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 matrix A to a Matrix Market formatted file.

Other

save_as_module([file_name, data]) Save the dictionary “data” into a module and shelf named save.

Wav sound files (scipy.io.wavfile)

read(file) Return the sample rate (in samples/sec) and data from a WAV file
write(filename, rate, data) Write a numpy array as a WAV file

Arff files (scipy.io.arff)

Module to read ARFF files, which are the standard data format for WEKA.

ARFF is a text file format which support numerical, string and data values. The format can also represent missing data and sparse data.

See the WEKA website for more details about arff format and available datasets.

Examples

>>> from scipy.io import arff
>>> content = """
... @relation foo
... @attribute width  numeric
... @attribute height numeric
... @attribute color  {red,green,blue,yellow,black}
... @data
... 5.0,3.25,blue
... 4.5,3.75,green
... 3.0,4.00,red
... """
>>> f = open('testdata.arff', 'w')
>>> f.write(content)
>>> f.close()
>>> data, meta = arff.loadarff('testdata.arff')
>>> data
array([(5.0, 3.25, 'blue'), (4.5, 3.75, 'green'), (3.0, 4.0, 'red')],
      dtype=[('width', '<f8'), ('height', '<f8'), ('color', '|S6')])
>>> meta
Dataset: foo
        width's type is numeric
        height's type is numeric
        color's type is nominal, range is ('red', 'green', 'blue', 'yellow', 'black')
loadarff(filename) Read an arff file.

Netcdf (scipy.io.netcdf)

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