emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] extract a region from a table and export it


From: John Kitchin
Subject: Re: [O] extract a region from a table and export it
Date: Tue, 14 Jun 2016 08:42:23 -0400
User-agent: mu4e 0.9.16; emacs 25.1.50.1

How about:

#+tblname: grades
|    | H1 | H2 | H3 |
|----+----+----+----|
| P1 | 90 | 89 | 91 |
| P2 | 67 | 65 | 78 |
| P3 | 99 | 98 | 97 |

collect row 0 and 2, columns 0 (P) and 2 (H2)


#+BEGIN_SRC emacs-lisp :var data=grades
(loop for i in '(0 2)
      with row = nil
      do
      (setq row (nth i data))
      collect (list (nth 0 row) (nth 2 row)))
#+END_SRC

#+RESULTS:
| P1 | 89 |
| P3 | 98 |




Uwe Brauer writes:

>>>> "John" == John Kitchin <address@hidden> writes:
>
>
>
>    > or, rows 0, 1 and 4.
>
>    > #+BEGIN_SRC emacs-lisp :var d=data
>    > (loop for i in '(0 1 4) collect (elt d i))
>    > #+END_SRC
>
> Ok the second code works now, and is almost what I want, but I need it
> mostly for columns, it is not obvious for me that corresponds in the
> syntax above to columns.
>
>
>    > #+RESULTS:
>    > | 1 | a |
>    > | 2 | r |
>    > | 8 | y |
>
>
>
>
>    > Uwe Brauer writes:
>
>    >> Hi
>    >> 
>    >> Is it possible to extract just say two regions from a huge table and
>    >> convert it to say CSV?
>    >> 
>    >> Uwe Brauer


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]