Skip to content

A capture magic? #32

@BoPeng

Description

@BoPeng

Motivated by vatlab/sos#869

We have a render magic that renders output from subkernels as markdown, html etc. We could provide a capture magic to capture output from subkernels. Something like,

  1. %capture --to var will capture the output (stdout) of subkernel to a variable var as string.
  2. %capture --to var --as json would use json.load() to parse the output and return a dictionary. %capture --to var --as csv would use csv.read() to parse the output as pandas.DataFrame.
  3. %capture --to var --as json --from outfile.txt would get the input from a file instead of standard output.

However, becaues capture and render are similar in functionality, we could add these features to the render magic. That is to say, we could add the following features to the render magic

  1. --from outfile.txt get input from a file instead of stdout, assuming the file would be generated by the subkernel.
  2. %render magic already supports JSON but we could add %render csv
  3. --to var %render displays output as cell output but we could save the results to a file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions