From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roland Everaert Subject: org babel table header sent to awk code block Date: Fri, 17 Feb 2017 13:33:39 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1145bb28a092180548b91f62 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cehjL-0003VW-2c for emacs-orgmode@gnu.org; Fri, 17 Feb 2017 07:33:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cehjK-0002MZ-2g for emacs-orgmode@gnu.org; Fri, 17 Feb 2017 07:33:43 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:36615) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cehjJ-0002MQ-SR for emacs-orgmode@gnu.org; Fri, 17 Feb 2017 07:33:42 -0500 Received: by mail-wm0-x232.google.com with SMTP id c85so13670065wmi.1 for ; Fri, 17 Feb 2017 04:33:41 -0800 (PST) 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" To: emacs-orgmode --001a1145bb28a092180548b91f62 Content-Type: text/plain; charset=UTF-8 Hi, I am trying to filter a table using the following awk code block. #+BEGIN_SRC awk :stdin list-example :var fstcol=1 :var seccol=3 :results output org BEGIN { print "|Host|Result" print "|-" } $seccol ~ /[0-9]{1,3}(\.[0-9]\{1,3\}){3}/ { print "|"$fstcol"|"$seccol } #+END_SRC The input table: #+NAME: list-example | A | B | C | |--------+--------------+--------------| | blabla | 12.147.5.74 | 10.23.31.189 | | test | 147.12.5.74 | | | hello | 79.147.64.74 | 10.23.31.189 | And the result is: #+RESULTS: #+BEGIN_SRC org | Host | Result | |--------+--------------| | A | C | | blabla | 10.23.31.189 | | test | | | hello | 10.23.31.189 | #+END_SRC Why the column names of the table are sent to awk? I have tried to set :colnames and :hlines, but that doesn't change the behavior. Regards. --001a1145bb28a092180548b91f62 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I am trying= to filter a table using the following awk code block.
#+BEGIN_SRC awk := stdin list-example :var fstcol=3D1 :var seccol=3D3 :results output org
= =C2=A0 BEGIN {
=C2=A0 print "|Host|Result"
=C2=A0 print &qu= ot;|-"
=C2=A0 }
=C2=A0 $seccol ~ /[0-9]{1,3}(\.[0-9]\{1,3\}){3}/=
=C2=A0 {
=C2=A0 print "|"$fstcol"|"$seccol
= =C2=A0 }
#+END_SRC

The input table:

=C2=A0=C2=A0=C2= =A0 #+NAME: list-example
=C2=A0=C2=A0=C2=A0 | A=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = B |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 C |=C2=A0=C2=A0=C2=A0 |--------+--------------+--------------|
=C2=A0=C2= =A0=C2=A0 | blabla |=C2=A0 12.147.5.74 | 10.23.31.189 |
=C2=A0=C2=A0=C2= =A0 | test=C2=A0=C2=A0 |=C2=A0 147.12.5.74 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |
=C2=A0=C2=A0=C2=A0 | = hello=C2=A0 | 79.147.64.74 | 10.23.31.189 |


And the result= is:


#+RESULTS:
#+BEGIN_SRC org
| Host=C2=A0=C2=A0 |=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Result |
|--------+--------------|
| A= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 C |
| blabla | 10.23.31.189 |
| test=C2=A0= =C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 |
| hello=C2=A0 | 10.23.31.189 |
#+END_SRC


Why the column names of the table are sent to awk?

I have = tried to set :colnames and :hlines, but that doesn't change the behavio= r.


Regards.
--001a1145bb28a092180548b91f62--