From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: using a table from one org-file as a variable in a code block in another org-file Date: Mon, 26 Nov 2012 10:32:02 -0700 Message-ID: <87lido46el.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Td2XG-000759-9X for emacs-orgmode@gnu.org; Mon, 26 Nov 2012 12:31:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Td2XE-0003KD-C6 for emacs-orgmode@gnu.org; Mon, 26 Nov 2012 12:31:58 -0500 Received: from mail-ia0-f169.google.com ([209.85.210.169]:58987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Td2XE-0003K7-7L for emacs-orgmode@gnu.org; Mon, 26 Nov 2012 12:31:56 -0500 Received: by mail-ia0-f169.google.com with SMTP id r4so10001397iaj.0 for ; Mon, 26 Nov 2012 09:31:55 -0800 (PST) In-Reply-To: (John Kitchin's message of "Mon, 26 Nov 2012 11:47:13 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Kitchin Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain John Kitchin writes: > Hi everyone, > > I have been using tables as variables for codeblocks on an org-file, e.g. > #+tblname: class-data > | user | oxide | xc | > | jkitchin | TiO2 | LDA| > ... > > #+BEGIN_SRC python :var data=class-data > from pylab import * > import numpy as np > > vol = [x[1] if x[1] != '' else np.nan for x in data] > B = [x[2] if x[2] != '' else np.nan for x in data ] > > scatter(vol, B) > xlabel('Volume ($\AA^3$)') > ylabel('Bulk modulus (GPa)') > title('All polymorphs of all oxides for all functionals') > show() > #+END_SRC > > This is a fantastic feature, since I can have some code that is > expensive to run create the table, but then have analysis code that is > quick, since it only reads the table. > > But, sometimes the tables are defined in other org-files. Is there a > way to specify a table from another org-file in the variable header? > > Something like this would be pretty handy: > > :var ./org-file.org::class-data > > Especially if I could click on it, and have it open the other org-file > with point at the table! > > Any thoughts? Thanks, > Hi John, This feature does exist, and your guess at the syntax is almost correct. To reference a variable named foo1 in a file named foo.org you would use the following syntax, ":var data=foo.org:foo1". See the attached foo.org and bar.org files for an example (in order to work they must be in the same directory). I'll make a note to mention this functionality in the documentation. Best, --=-=-= Content-Type: text/x-org Content-Disposition: attachment; filename=foo.org #+name: foo1 | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | --=-=-= Content-Type: text/x-org Content-Disposition: attachment; filename=bar.org #+begin_src sh :var data=foo.org:foo1 echo "$data" #+end_src #+RESULTS: | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | --=-=-= Content-Type: text/plain > > 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 > -- Eric Schulte http://cs.unm.edu/~eschulte --=-=-=--