From: dmg <dmg@turingmachine.org>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: wishful thinking: using SQL to process tables. in the meantime, use R
Date: Wed, 20 Jul 2016 18:13:53 -0700 [thread overview]
Message-ID: <CAEBXXD83z0sVsJpv7641esLmFAzh4-PX2foEMs41o1HP0aGAsw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1207 bytes --]
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,
https://stat.ethz.ch/R-manual/R-devel/library/base/html/merge.html
but there is nothing like the power of SQL to process tables, though.
--
--dmg
---
Daniel M. German
http://turingmachine.org
[-- Attachment #2: Type: text/html, Size: 3549 bytes --]
next reply other threads:[~2016-07-21 1:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 1:13 dmg [this message]
2016-07-21 17:35 ` wishful thinking: using SQL to process tables. in the meantime, use R Thierry Banel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEBXXD83z0sVsJpv7641esLmFAzh4-PX2foEMs41o1HP0aGAsw@mail.gmail.com \
--to=dmg@turingmachine.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).