OpenSesame
Rapunzel Code Editor
DataMatrix
Support forum
Python Tutorials
MindProbe
Python videos

datamatrix.io

A set of functions for reading and writing DataMatrix objects from and to file.

from datamatrix import io

function readbin(path)

Reads a DataMatrix from a binary file. This format allows you to read and write DataMatrix objects with unloaded columns, i.e. columns that are too large to fit in memory.

Example:

dm = io.readbin('data.dm')

Version note: New in 1.0.0

Arguments:

  • path -- The path to the binary file.

Returns:

A DataMatrix.

function readpickle(path)

Reads a DataMatrix from a pickle file.

Example:

dm = io.readpickle('data.pkl')

Arguments:

  • path -- The path to the pickle file.

Returns:

A DataMatrix.

function readtxt(path, delimiter=u',', quotechar=u'"', default_col_type=)

Reads a DataMatrix from a csv file.

Example:

dm = io.readtxt('data.csv')

Version note: As of 0.10.7, byte-order marks (BOMs) are silently stripped from column names.

Arguments:

  • path -- The path to the pickle file.

Keywords:

  • delimiter -- The delimiter characer.
    • Default: ','
  • quotechar -- The quote character.
    • Default: '"'
  • default_col_type -- The default column type.
    • Default:

Returns:

A DataMatrix.

function readxlsx(path, default_col_type=, sheet=None)

Reads a DataMatrix from an Excel 2010 xlsx file.

Example:

dm = io.readxlsx('data.xlsx')

Arguments:

  • path -- The path to the xlsx file.

Keywords:

  • default_col_type -- The default column type.
    • Default:
  • sheet -- The name of a sheet, or None to open the active sheet. The activate sheet is not necessarily the first sheet. (New in 0.7.0)
    • Default: None

Returns:

A DataMatrix.

function writebin(dm, path)

Reads a DataMatrix to a binary file. This format allows you to read and write DataMatrix objects with unloaded columns, i.e. columns that are too large to fit in memory.

Example:

io.writebin(dm, 'data.dm')

Version note: New in 1.0.0

Arguments:

  • dm -- The DataMatrix to write.
  • path -- The path to the binary file.

function writepickle(dm, path, protocol=-1)

Writes a DataMatrix to a pickle file.

Example:

io.writepickle(dm, 'data.pkl')

Arguments:

  • dm -- The DataMatrix to write.
  • path -- The path to the pickle file.

Keywords:

  • protocol -- The pickle protocol.
    • Default: -1

function writetxt(dm, path, delimiter=u',', quotechar=u'"')

Writes a DataMatrix to a csv file.

Example:

io.writetxt(dm, 'data.csv')

Arguments:

  • dm -- The DataMatrix to write.
  • path -- The path to the pickle file.

Keywords:

  • delimiter -- The delimiter characer.
    • Default: ','
  • quotechar -- The quote character.
    • Default: '"'

function writexlsx(dm, path)

Writes a DataMatrix to an Excel 2010 xlsx file. The first sheet will contain a regular table with all non-series columns. SeriesColumns are saved as individual sheets.

Example:

io.writexlsx(dm, 'data.xlsx')

Arguments:

  • dm -- The DataMatrix to write.
  • path -- The path to the xlsx file.