emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] wishful thinking: using SQL to process tables. in the meantime,


From: Thierry Banel
Subject: Re: [O] wishful thinking: using SQL to process tables. in the meantime, use R
Date: Thu, 21 Jul 2016 19:35:02 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

Le 21/07/2016 03:13, dmg a écrit :
Hi everybody,

I was wondering if there was a way to join two tables given
a common column. I searched but found nothing.

it would be awesome to be able to process tables in SQLITE.
something like this:

#+BEGIN_SRC sqlite :var a=table1 b=table2  :colnames yes
  select * from $a join $b using column;
#+END_SRC

I think it is not that hard. The infrastructure is there already.
It is just a matter of creating temp tables (this is the major part missing
which implies making a create statement from the table, but given
that sqlite is very type agnostic, it might not be hard), 
load them from the CSV files
the execute the block. A db parameter might be needed
for a scratch database file, but it could be a temporary one if
none is provided.

But in the meantime, it occurred to me, it is simple in R to do the join
and might be useful to others:

#+BEGIN_SRC R :var a=table1 b=table2 :results value :colnames yes
merge(a,b,by.x="column")
#+END_SRC

merge can do left joins, right joins, full joins, joins, 


but there is nothing like the power of SQL to process tables, though.

--
--dmg

---
Daniel M. German
http://turingmachine.org

You may want to try orgtbl-join
  https://github.com/tbanel/orgtbljoin
Available on Melpa (M-x package-install orgtbl-join)
It is pure Emacs (no external dependencies)




reply via email to

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