Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A capture magic? #32

Closed
BoPeng opened this issue Jan 25, 2018 · 1 comment
Closed

A capture magic? #32

BoPeng opened this issue Jan 25, 2018 · 1 comment

Comments

@BoPeng
Copy link
Contributor

BoPeng commented Jan 25, 2018

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.
@BoPeng
Copy link
Contributor Author

BoPeng commented Jan 26, 2018

For consistency, I chose a syntax that is similar to magic %render, namely

%capture csv --to var

without the proposed --as csv.

@BoPeng BoPeng closed this as completed Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant