From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: searching for csv utilities Date: Wed, 03 Jun 2015 13:21:01 -0400 Message-ID: <87d21ciu82.fsf@alphaville.usersys.redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0CLt-0008Ah-8M for emacs-orgmode@gnu.org; Wed, 03 Jun 2015 13:21:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0CLq-00028q-2h for emacs-orgmode@gnu.org; Wed, 03 Jun 2015 13:21:17 -0400 Received: from plane.gmane.org ([80.91.229.3]:53991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0CLp-00028G-Nq for emacs-orgmode@gnu.org; Wed, 03 Jun 2015 13:21:14 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Z0CLl-0005ug-6x for emacs-orgmode@gnu.org; Wed, 03 Jun 2015 19:21:09 +0200 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 03 Jun 2015 19:21:09 +0200 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 03 Jun 2015 19:21:09 +0200 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: emacs-orgmode@gnu.org Jude DaShiell writes: > This is a piece of a modified ecm that may show what's going on. > > cut here. > |----------------------+---------+--------+--------+--------| > | Averages: | | | | | > | Counts: | | | | | > | Maximums: | | | | | > | Medians: | | | | | > | Minimums: | | | | | > | Modes: | | | | | > | Standard Deviations: | | | | | > | Sums: | 108.69) | 70.45) | 66.62) | 92.93) | > |----------------------+---------+--------+--------+--------| > #+TBLFM: @>$2..@>$>=vmean(@I..@>>;%.2f) > The syntax is wrong - the format has to go *outside* the parens of the function. Also the row spec is almost certainly wrong - something like the following is needed (but see below for a more exact specification of what the table looks like and what the actual TBLFM line should be): #+TBLFM: @>$2..@>$>=vmean(@I..@II);%.2f The @I..@II restricts the range of rows to be considered to be between the first and the second hline. IOW, the assumption is that you have three areas in your table: a header line, followed by an hline, a number of rows with data, followed by an hline and a number of rows containing calculated statistics, followed by an (optional) hline - something like this: | Date | Sys | Dia | Pul | Sugar | |----------------------+--------+-------+-------+-------| | [2014-04-27 Sun] | 125 | 88 | 78 | 92 | | [2014-04-28 Mon] | 102 | 88 | 86 | 92 | |----------------------+--------+-------+-------+-------| | Averages: | 113.50 | 88.00 | 82.00 | 92.00 | | Counts: | 2 | 2 | 2 | 2 | | Maximums: | 125.00 | 88.00 | 86.00 | 92.00 | | Medians: | | | | | | Minimums: | | | | | | Modes: | | | | | | Standard Deviations: | | | | | | Sums: | | | | | |----------------------+--------+-------+-------+-------| #+TBLFM: @>>>>>>>>$2..@>>>>>>>>$> = vmean(@I..@II);%.2f :: @>>>>>>>$2..@>>>>>>>$> = vcount(@I..@II) :: @>>>>>>$2..@>>>>>>$> = vmax(@I..@II);%.2f The only challenges left are to refer to the correct row and to find the appropriate calc function for the statistic at hand. Unfortunately, org mode is not particularly flexible in referring to cells (although it is a *lot* more flexible than it used to be). In particular, referring to the "Averages:" row can not be done simply (afaik): it's the first row after the second hline, so you'd think that you can refer to it as @II+1 but hline-relative references are not allowed on the LHS, so the best that I could do is refer to it as the eightth column from the bottom: @>>>>>>>> and similarly for the others - looks like chicken scratchings (or what amounts to the same thing, Perl :-) ). With that caveat, the above TBLFM line will calculate the first three of the eight statistics you want - the rest can be done similarly with the calc functions vmedian, vmin, vmode, vstdev and vsum; but you can see it's getting unwieldy, particularly since the whole thing has to be on one line (or has that changed? I'm not keeping track any longer...) I believe that you are (partially or completely?) blind, which makes this all the more difficult: counting how many "greater than" signs are in each of those row specs is a pain for anybody, but I can't even imagine how a blind person would deal with it. > I haven't even attempted the rest of the math since I have no way to > predict where any of the results will land. > On Tue, 2 > Jun 2015, Jonathan Leech-Pepin wrote: > >> Date: Tue, 2 Jun 2015 08:04:20 >> From: Jonathan Leech-Pepin >> To: Jude DaShiell >> Cc: Org Mode Mailing List >> Subject: Re: [O] searching for csv utilities >> >> Hello, >> >> On 2 June 2015 at 07:44, Jude DaShiell wrote: >> >>> | Date | Sys | Dia | Pul | Sugar | >>> |------------------+-------------------+-----+-----+-------| >>> | [2014-04-27 Sun] | 125 | 88 | 78 | 92 | >>> | [2014-04-28 Mon] | 102 | 88 | 86 | 92 | >>> | Averages: | =$2=vmean(@<..@>) | | | | >>> #+TBLFM: $2=$2=vmean(@<..@>) >>> >> >> The formula in question is the culprit in this case (at least as stated >> there). >> >> : $2=$2=vmean(@<..@>) >> >> Second column is equal to the second column which is equal to the mean of >> all the values in the second column (including the header "Sys"). >> >> If you change the table as follows: >> >> | Date | Sys | Dia | Pul | Sugar | >> |------------------+-------+-----+-----+-------| >> | [2014-04-27 Sun] | 125 | 88 | 78 | 92 | >> | [2014-04-28 Mon] | 102 | 88 | 86 | 92 | >> |------------------+-------+-----+-----+-------| >> | Averages: | 113.5 | 88 | 82 | 92 | >> #+TBLFM: @>$2..@>$>=vmean(@I..@II) >> >> All the values will properly compute. If you want to avoid the second >> HLINE above Averages: then change =@II= to =@>>= (penultimate row) >> >> Regards, >> Jon >> >> >>> This is a cut down version of my full record set. Sometimes when I key >>> formulas in I get ?ERROR back for a result after keying in c-c+c-c once >>> I've completed the formula and hit tab. If I do c-u+c-c+c-c that sometimes >>> generated ?ERROR. Other times I key in a formula and the cursor gets >>> locked and I have to hit c-g to exit #+TBLFM: mode; I don't know what's >>> actually happening when that situation arises since other than suddenly >>> finding the cursor locked I can neither tell what state I'm in or if a few >>> more keystrokes are needed or if I've generated an error situation. >>> >>> -- >>> >>> >>> >> HTH, Nick