emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jeremie Juste <jeremiejuste@gmail.com>
To: emacs-orgmode@gnu.org
Cc: tyler@plantarum.ca
Subject: [FR] ob-awk.el specifying a delimeter argument in for output
Date: Sun, 05 Mar 2023 10:50:50 +0100	[thread overview]
Message-ID: <87ttyzcyrp.fsf@gmail.com> (raw)

Hello,

ob-awk has proven very valuable to me lately so many
thanks for maintaining it. 

First of all let me specify that I'm a beginner user of awk and I don't
know if I'm using ob-awk as it is intended, so I'll be glad for any
suggestions. Let me explain further:


* Default behavior

If I have a csv file with comma separated values, I get the output as an
org table.

;; test.csv
123,0,123


#+begin_src awk :in-file test.csv :cmd-line -F ","
{print $0}
#+end_src

#+RESULTS:
| 123 | 0 | 123 |

* Request 

However If I have a csv file with say semi column delimited values (;)
I don't get the org table as output

#+begin_src awk :in-file test1.csv :cmd-line -F ";"
{print $0}
#+end_src

#+RESULTS:
: 123;0;123


In my opinion, this could be fixed if we could read the :cmd-line
parameter -F  and use the delimeter argument ; as a parameter to the
following function

modified   lisp/ob-awk.el
@@ -93,7 +93,7 @@ This function is called by `org-babel-execute-src-block'."
 	   results
 	   (let ((tmp (org-babel-temp-file "awk-results-")))
 	     (with-temp-file tmp (insert results))
-	     (org-babel-import-elisp-from-file tmp)))))
+	     (org-babel-import-elisp-from-file tmp ";")))))


Would this be the right way to do think about this issue? 

Best regards,
Jeremie

PS Note that we have a samilar issue in ob-shell
where the delimiter is by default a comma. 

#+begin_src shell
  echo '192;168;1;200' | awk -F ";"   '{print $0}'     
#+end_src

#+RESULTS:
: 192;168;1;200



#+begin_src shell
  echo '192,168,1,200' | awk -F ","   '{print $0}'     
#+end_src

#+RESULTS:
| 192 | 168 | 1 | 200 |


             reply	other threads:[~2023-03-05  9:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-05  9:50 Jeremie Juste [this message]
2023-03-05 12:37 ` [FR] ob-awk.el specifying a delimeter argument in for output Ihor Radchenko
2023-03-06  7:36   ` Jeremie Juste
2023-03-06  7:47     ` Jeremie Juste
2023-03-06 10:00 ` Max Nikulin

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=87ttyzcyrp.fsf@gmail.com \
    --to=jeremiejuste@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tyler@plantarum.ca \
    /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).