Re: [O] Trouble with Tables and Python

2014-04-18 Thread Sebastien Vauban
John Kitchin wrote:
 I also find you want :results output raw

 if you are printing a table or printing org. This is something I have never
 found satisfying, especially for long tables or outputs it is tedious to
 have to delete the old output by hand before rerunning it. I have not found
 any other sets of options that do what I want, e.g. changing raw to org
 results in the section being wrapped in #+begin_org/end_org, which is
 usually not what I want. I usually do want the raw output.

IIUC, that's one good reason to use the :results drawer thing.

Best regards,
  Seb

-- 
Sebastien Vauban




Re: [O] Trouble with Tables and Python

2014-04-16 Thread Martin Schöön
Thanks for the explanations and guiding. Now this works the way I want it
to.

-- 
Martin Schöön

http://hem.bredband.net/b262106/index.html


[O] Trouble with Tables and Python

2014-04-15 Thread Martin Schöön
This is my first post here...

I have been using org-mode as a pure TODO-tool for some time but this
winter I realised it could be used for much more and I have been
experimenting with mixing in LaTeX and Python for fun and because I find
literate programming a particularly sane idea (I am a HW engineer).

Less than I week ago I started to look into using tables for input and
output to/from Python scripts. I was inspired by something I found at
http://kitchingroup.cheme.cmu.edu/ . The enclosed example 1 file is a
pruned version of the org-file I found there. If I run the embedded Python
script using C-c C-c I don't get the table shown in the example. Instead I
get none on the row following #+RESULTS:

If I change :results raw to :results output I do get the table but
'wrapped' in #+begin_example and #+end_example as shown in  the
enclosed example 2 file. I have done some further testing/changes in that
file (adding some stuff to the top of the file and changing the formatting
of the print statements) none of which changed the extra wrapping of the
table. When I export to LaTeX - PDF the table does not show up in the end
result.

Let's move over to the third example file and the real mystery. This all my
own code. Reading data from the first table works just fine and the same
goes for the calculations. The output table, however, is different from
that of example 2. The 'wrapper' is gone but each row is starting with :
. Where does that come from? Why does it differ from example 2? If my
results differ from someone else's (different install/versions etc) -- OK.
But how can I get differences like this on my own? To my  un-trained eyes
the print statements of examples 2 and 3 look very similar. (But, the first
things that go blind are the eyes... probably something blatantly obvious
once pointed out to me.)

OS: #! Linux (Based on Debian stable, 64-bit)
Emacs: 23.4.1
Org-mode: 8.2.5h
Python: 2.7.3

TIA,
-- 
Martin Schöön

http://hem.bredband.net/b262106/index.html


table_making_example_1.org
Description: Binary data


table_making_example_2.org
Description: Binary data


table_making_example_3.org
Description: Binary data


Re: [O] Trouble with Tables and Python

2014-04-15 Thread Nick Dokos
Martin Schöön martin.sch...@gmail.com writes:

 ...  Let's move over to the third example file and the real
 mystery. This all my own code. Reading data from the first table works
 just fine and the same goes for the calculations. The output table,
 however, is different from that of example 2. The 'wrapper' is gone
 but each row is starting with : . Where does that come from? Why
 does it differ from example 2? If my results differ from someone
 else's (different install/versions etc) -- OK. But how can I get
 differences like this on my own? To my  un-trained eyes the print
 statements of examples 2 and 3 look very similar. (But, the first
 things that go blind are the eyes... probably something blatantly
 obvious once pointed out to me.)


2) and 3) are exactly the same thing (see section 11.3, Literal
examples in the org manual.)

The only difference is the length of the output - short output is
prepended by a colon, long output is wrapped in
#+BEGIN_EXAMPLE/#+END_EXAMPLE. What is short and what is long is
determined by the value of org-babel-min-lines-for-block-output
(default: 10) which you can customize.

--
Nick




Re: [O] Trouble with Tables and Python

2014-04-15 Thread John Kitchin
I should probably confess to having this in my .emacs files:

;; language specific headers. I think this comes before the defaults
(setq org-babel-default-header-args:emacs-lisp
  (cons '(:results . value replace)
(assq-delete-all :results org-babel-default-header-args)))

;; set default :results to output
(setq org-babel-default-header-args
  (cons '(:results . output replace)
(assq-delete-all :results org-babel-default-header-args)))

;; set default exports to both code and results
(setq org-babel-default-header-args
  (cons '(:exports . both)
(assq-delete-all :exports org-babel-default-header-args)))

These things change the default behaviors for the results. I almost always
want output as results, and not value (the regular default), except when
coding in emacs-lisp where the value make sense to me.

That would certainly be a point of confusion ;)

I also find you want :results output raw

if you are printing a table or printing org. This is something I have never
found satisfying, especially for long tables or outputs it is tedious to
have to delete the old output by hand before rerunning it. I have not found
any other sets of options that do what I want, e.g. changing raw to org
results in the section being wrapped in #+begin_org/end_org, which is
usually not what I want. I usually do want the raw output.

I hope that clarifies where some of your differences might be coming from.

John

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



On Tue, Apr 15, 2014 at 5:18 PM, Martin Schöön martin.sch...@gmail.comwrote:

 This is my first post here...

 I have been using org-mode as a pure TODO-tool for some time but this
 winter I realised it could be used for much more and I have been
 experimenting with mixing in LaTeX and Python for fun and because I find
 literate programming a particularly sane idea (I am a HW engineer).

 Less than I week ago I started to look into using tables for input and
 output to/from Python scripts. I was inspired by something I found at
 http://kitchingroup.cheme.cmu.edu/ . The enclosed example 1 file is a
 pruned version of the org-file I found there. If I run the embedded Python
 script using C-c C-c I don't get the table shown in the example. Instead I
 get none on the row following #+RESULTS:

 If I change :results raw to :results output I do get the table but
 'wrapped' in #+begin_example and #+end_example as shown in  the
 enclosed example 2 file. I have done some further testing/changes in that
 file (adding some stuff to the top of the file and changing the formatting
 of the print statements) none of which changed the extra wrapping of the
 table. When I export to LaTeX - PDF the table does not show up in the
 end result.

 Let's move over to the third example file and the real mystery. This all
 my own code. Reading data from the first table works just fine and the same
 goes for the calculations. The output table, however, is different from
 that of example 2. The 'wrapper' is gone but each row is starting with :
 . Where does that come from? Why does it differ from example 2? If my
 results differ from someone else's (different install/versions etc) --
 OK. But how can I get differences like this on my own? To my  un-trained
 eyes the print statements of examples 2 and 3 look very similar. (But, the
 first things that go blind are the eyes... probably something blatantly
 obvious once pointed out to me.)

 OS: #! Linux (Based on Debian stable, 64-bit)
 Emacs: 23.4.1
 Org-mode: 8.2.5h
 Python: 2.7.3

 TIA,
 --
 Martin Schöön

 http://hem.bredband.net/b262106/index.html