emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Sharing variables between source blocks without session
@ 2021-03-16  8:56 Loris Bennett
  2021-03-16  9:16 ` Loris Bennett
  2021-03-16 13:28 ` Eric S Fraga
  0 siblings, 2 replies; 13+ messages in thread
From: Loris Bennett @ 2021-03-16  8:56 UTC (permalink / raw)
  To: Org Mode Mailing List

Hi,

I have a 'sh' source block which produces a table which I then want to
plot with a 'python' source block:

#+NAME: code;raw_data
#+HEADER: :var user="loris"
#+BEGIN_SRC sh
  ps -u loris -o etimes=
#+END_SRC                                                                                                                                                                                                        

#+NAME: tab;raw_data
#+RESULTS: code;raw_data...

#+HEADER: :var df=tab;raw_data
#+HEADER: :var user="loris"
#+BEGIN_SRC python :results file :var f="process_times.pdf"
  import numpy as np
  import matplotlib.pyplot as plt
  # flatten list
  x = [item for sublist in df for item in sublist]
  plt.hist(x, bins=10)
  plt.xlabel("time [s]")
  plt.ylabel("number of processes")
  plt.title("user: " + user)
  plt.savefig(f) 
  return f
#+END_SRC

How can I avoid having to declare the variable 'user' for both blocks?

Cheers,

Loris

-- 
This signature is currently under construction.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-03-22  7:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-16  8:56 Sharing variables between source blocks without session Loris Bennett
2021-03-16  9:16 ` Loris Bennett
2021-03-16 13:28 ` Eric S Fraga
2021-03-18 13:21   ` Loris Bennett
2021-03-18 15:56     ` Eric S Fraga
2021-03-19  6:50       ` Loris Bennett
2021-03-18 17:59     ` Cook, Malcolm
2021-03-19  6:38       ` Loris Bennett
2021-03-19  7:04         ` Loris Bennett
2021-03-19 13:26         ` Eric S Fraga
2021-03-19 13:59           ` Loris Bennett
2021-03-19 14:26             ` Eric S Fraga
2021-03-22  7:39               ` Loris Bennett

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).