{ } Raw JSON

bundles / nbformat 5.11.1 / nbformat / read

function

nbformat:read

source: /nbformat/__init__.py:140

Signature

def read(fp, as_version, capture_validation_error = None, **kwargs)

Summary

Read a notebook from a file as a NotebookNode of the given version.

Extended Summary

The string can contain a notebook of any version. The notebook will be returned as_version, converting, if necessary.

Notebook format errors will be logged.

Parameters

fp : file or str

A file-like object with a read method that returns unicode (use io.open() in Python 2), or a path to a file.

as_version : int

The version of the notebook format to return. The notebook will be converted, if necessary. Pass nbformat.NO_CONVERT to prevent conversion.

capture_validation_error : dict, optional

If provided, a key of "ValidationError" with a value of the ValidationError instance will be added to the dictionary.

Returns

nb : NotebookNode

The notebook that was read.

Aliases

  • nbformat.read