[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to get a table into a variable in a shell code block?
From: |
William Denton |
Subject: |
How to get a table into a variable in a shell code block? |
Date: |
Sat, 3 Apr 2021 14:14:56 -0400 (EDT) |
User-agent: |
Alpine 2.22 (DEB 394 2020-01-19) |
Let's say I have a table like this:
#+NAME: numbers
| one |
| two |
| three |
I want to run through those numbers in a shell code block, but it I pass in
table as a variable, it only sees the first number.
#+begin_src shell :results output :var n=numbers
echo $n
#+end_src
#+RESULTS:
: one
In Ruby it sees the numbers as an array:
#+begin_src ruby :results output :var n=numbers
puts n
puts n.class
#+end_src
#+RESULTS:
: one
: two
: three
: Array
And in R sees them as a data.table with one column. Both are very easy to
iterate over, of course.
I looked at the docs, but didn't see this covered, then I looked at ob-shell.el
and saw the "org-babel--variable-assignments:bash_array" function, which might
or might not be relevant, but it's all beyond my comprehension.
Is there a way to get my shell code seeing all of the elements in the column?
Thanks,
Bill
--
William Denton :: Toronto, Canada --- Listening to Art:
https://listeningtoart.org/
https://www.miskatonic.org/ --- GHG.EARTH: https://ghg.earth/
Caveat lector. --- STAPLR: https://staplr.org/
- How to get a table into a variable in a shell code block?,
William Denton <=