Skip to content

ExcelReadOptions(sheet=None, column_names=ColumnNames.CLEANED, missing_texts=None) Source

Settings of an Excel file read by Table.from_excel.

Added in version 0.1.0

Parameters:

  • sheet (str | None, default: None)

    The name of the sheet read, the first sheet when omitted.

  • column_names (ColumnNames, default: ColumnNames.CLEANED)

    Whether the column names are cleaned, ColumnNames.CLEANED by default: the spaces, tabs and line breaks at the start and the end of each name are removed. ColumnNames.KEPT keeps the names as written.

  • missing_texts (list[str] | None, default: None)

    The texts read as missing values, compared with the whole value of each cell. When omitted, the texts pandas reads as missing: "", "#N/A", "#N/A N/A", "#NA", "-1.#IND", "-1.#QNAN", "-NaN", "-nan", "1.#IND", "1.#QNAN", "<NA>", "N/A", "NA", "NULL", "NaN", "None", "n/a", "nan" and "null". A given list replaces them: [] reads no value as missing, not even an empty one: an empty cell is then read as an empty text.

Raises:

  • InvalidTypeError

    When a setting is not of the type its annotation names.

  • InvalidSheetNameError

    When the name is empty, longer than 31 characters, or holds [ ] : * ? / \, which Excel refuses.

Examples:

import tempfile
from pathlib import Path
import numdaplot as ndp

path = Path(tempfile.mkdtemp()) / "sales.xlsx"
prices = ndp.Table.from_arrays({"price": ndp.Array.from_list([1.5])})
prices.to_excel(path, ndp.ExcelWriteOptions(sheet="Sales"))
ndp.Table.from_excel(path, ndp.ExcelReadOptions(sheet="Sales"))
#     price
#   FLOAT64
# 0     1.5