Wolfram Language

User Interface Enhancements

Notebook Document Processing

Since Version 3, notebooks have been saved as symbolic expressions that can easily be loaded and processed into the Wolfram Language, but doing so requires a significant understanding of the notebook's symbolic representation. NotebookImport clears that hurdle by making it simple to pull text, graphics, and code from notebooks.

Import all "Notes"-styled cells found in the documentation for Cos, convert them to plain text strings, and return them in a nicely formatted table.

show complete Wolfram Language input
In[1]:=
Click for copyable input
docNotebook = FileNameJoin[{$InstallationDirectory, "Documentation", "English", "System", "ReferencePages", "Symbols", "Cos.nb"}]; makeGrid[data_] := Grid[List /@ data, Alignment -> Left, Dividers -> All, Spacings -> {1, 1}, Background -> {None, {{Lighter[ Blend[{Gray, Hue[RandomReal[], .8, 1]}, {.4, .6}], .8], White}}}]
In[2]:=
Click for copyable input
makeGrid[Text /@ NotebookImport[docNotebook, "Notes" -> "Text"]]
Out[2]=

Samples of all extracted inputs.

In[3]:=
Click for copyable input
makeGrid[Take[NotebookImport[docNotebook, "Input"], 9]]
Out[3]=

Show the inputs in "InactiveExpression" form.

In[4]:=
Click for copyable input
makeGrid[Take[ NotebookImport[docNotebook, "Input" -> "InactiveExpression"], 9]]
Out[4]=

Samples of all the graphical outputs.

In[5]:=
Click for copyable input
Take[Cases[ NotebookImport[docNotebook, "Output"], _Graphics | _Image | _Graphics3D], 4]
Out[5]=

Samples of all extracted example texts.

In[6]:=
Click for copyable input
makeGrid[Take[NotebookImport[docNotebook, "ExampleText" -> "Text"], 9]]
Out[6]=

Related Examples

de es fr ja ko pt-br ru zh