pyexcel.Sheet

class pyexcel.Sheet(sheet=None, name='pyexcel sheet', name_columns_by_row=-1, name_rows_by_column=-1, colnames=None, rownames=None, transpose_before=False, transpose_after=False)[source]

Two dimensional data container for filtering, formatting and iteration

Sheet is a container for a two dimensional array, where individual cell can be any Python types. Other than numbers, value of these types: string, date, time and boolean can be mixed in the array. This differs from Numpy’s matrix where each cell are of the same number type.

In order to prepare two dimensional data for your computation, formatting functions help convert array cells to required types. Formatting can be applied not only to the whole sheet but also to selected rows or columns. Custom conversion function can be passed to these formatting functions. For example, to remove extra spaces surrounding the content of a cell, a custom function is required.

Filtering functions are used to reduce the information contained in the array.

Variables:
  • name – sheet name. use to change sheet name
  • row – access data row by row
  • column – access data column by column

Example:

>>> import pyexcel as p
>>> content = {'A': [[1]]}
>>> b = p.get_book(bookdict=content)
>>> b
A:
+---+
| 1 |
+---+
>>> b[0].name
'A'
>>> b[0].name = 'B'
>>> b
B:
+---+
| 1 |
+---+
__init__(sheet=None, name='pyexcel sheet', name_columns_by_row=-1, name_rows_by_column=-1, colnames=None, rownames=None, transpose_before=False, transpose_after=False)[source]

Constructor

Parameters:
  • sheet – two dimensional array
  • name – this becomes the sheet name.
  • name_columns_by_row – use a row to name all columns
  • name_rows_by_column – use a column to name all rows
  • colnames – use an external list of strings to name the columns
  • rownames – use an external list of strings to name the rows

Methods

Attributes