all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* simple script to convert txt tables to Org-mode tables on the command line
@ 2013-01-07 18:27 Eric Schulte
  2013-01-07 18:37 ` Jambunathan K
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Eric Schulte @ 2013-01-07 18:27 UTC (permalink / raw)
  To: Org Mode Mailing List

I found the need to write this today, figured I'd share on the off
chance anyone else has a need for this sort of script.

  txt2org --- convert tab-separated data to org-mode tables
  http://orgmode.org/worg/org-hacks.html#sec-3-4

Cheers,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 18:27 simple script to convert txt tables to Org-mode tables on the command line Eric Schulte
@ 2013-01-07 18:37 ` Jambunathan K
  2013-01-07 18:48   ` Eric Schulte
  2013-01-07 18:54 ` Nick Dokos
  2013-01-07 20:09 ` Bastien
  2 siblings, 1 reply; 11+ messages in thread
From: Jambunathan K @ 2013-01-07 18:37 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Eric Schulte <schulte.eric@gmail.com> writes:

> I found the need to write this today, figured I'd share on the off
> chance anyone else has a need for this sort of script.
>
>   txt2org --- convert tab-separated data to org-mode tables
>   http://orgmode.org/worg/org-hacks.html#sec-3-4

Is it different from 

        M-x org-table-import RET


> Cheers,

-- 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 18:37 ` Jambunathan K
@ 2013-01-07 18:48   ` Eric Schulte
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Schulte @ 2013-01-07 18:48 UTC (permalink / raw)
  To: Jambunathan K; +Cc: Org Mode Mailing List

Jambunathan K <kjambunathan@gmail.com> writes:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> I found the need to write this today, figured I'd share on the off
>> chance anyone else has a need for this sort of script.
>>
>>   txt2org --- convert tab-separated data to org-mode tables
>>   http://orgmode.org/worg/org-hacks.html#sec-3-4
>
> Is it different from 
>
>         M-x org-table-import RET
>

Yes, it is a shell script and not an Emacs Lisp function, hence it can
be used in different contexts.  Also, it probably isn't quite as nice in
terms of right or left aligning column contents.

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 18:27 simple script to convert txt tables to Org-mode tables on the command line Eric Schulte
  2013-01-07 18:37 ` Jambunathan K
@ 2013-01-07 18:54 ` Nick Dokos
  2013-01-07 20:09 ` Bastien
  2 siblings, 0 replies; 11+ messages in thread
From: Nick Dokos @ 2013-01-07 18:54 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Eric Schulte <schulte.eric@gmail.com> wrote:

> I found the need to write this today, figured I'd share on the off
> chance anyone else has a need for this sort of script.
> 
>   txt2org --- convert tab-separated data to org-mode tables
>   http://orgmode.org/worg/org-hacks.html#sec-3-4
> 

As an alternative, the command

  M-x org-table-convert-region

does much of the dirty work - but you are on your own for hlines.

Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 18:27 simple script to convert txt tables to Org-mode tables on the command line Eric Schulte
  2013-01-07 18:37 ` Jambunathan K
  2013-01-07 18:54 ` Nick Dokos
@ 2013-01-07 20:09 ` Bastien
  2013-01-07 20:33   ` Achim Gratz
  2 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2013-01-07 20:09 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Eric Schulte <schulte.eric@gmail.com> writes:

> I found the need to write this today, figured I'd share on the off
> chance anyone else has a need for this sort of script.
>
>   txt2org --- convert tab-separated data to org-mode tables
>   http://orgmode.org/worg/org-hacks.html#sec-3-4

Neat!

In the same vein, the next release of Clojure (1.5) includes
a way to export to Org mode tables:

https://github.com/clojure/clojure/blob/master/changes.md#28-clojurepprintprint-table-output-compatible-with-emacs-org-mode

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 20:09 ` Bastien
@ 2013-01-07 20:33   ` Achim Gratz
  2013-01-07 20:54     ` Eric Schulte
  0 siblings, 1 reply; 11+ messages in thread
From: Achim Gratz @ 2013-01-07 20:33 UTC (permalink / raw)
  To: emacs-orgmode

Bastien writes:
> In the same vein, the next release of Clojure (1.5) includes
> a way to export to Org mode tables:

While we are talking about exporting tables to/from Org: Start a session
from sudoku.el and use this org file to easily import Sudoku from a
paper or book into sudoku.el and maybe keep track of what you did.  Not
the most elegant code for dealing with the lists structures, but it gets
the job done.

--8<---------------cut here---------------start------------->8---
#+NAME: export-sudoku
#+BEGIN_SRC emacs-lisp :var table=() :hlines no :results output silent
  (setq custom-puzzles 
        (list
         (mapcar
          (lambda (row)
            (mapcar
             (lambda (entry)
               (if (stringp entry) 0 entry))
             row))
          (remove 'hline table))))
#+END_SRC
#+NAME: import-sudoku
#+BEGIN_SRC emacs-lisp :results value :hlines yes
  (let (board
        (index 0))
  (setq board (mapcar
               (lambda (row)
                 (mapcar
                  (lambda (entry)
                    (if (zerop entry) "" entry))
                  row))
               current-board))
  (list
   (nth 0 board) (nth 1 board) (nth 2 board)
   'hline
   (nth 3 board) (nth 4 board) (nth 5 board)
   'hline
   (nth 6 board) (nth 7 board) (nth 8 board)))
#+END_SRC

#+TBLNAME: Test
| 3 |   | 2 |   |   |   | 5 |   | 8 |
|   | 9 |   | 3 |   | 5 |   | 6 |   |
| 6 |   |   |   | 7 |   |   |   | 4 |
|---+---+---+---+---+---+---+---+---|
|   | 8 |   | 1 |   | 4 |   | 2 |   |
|   |   | 9 |   |   |   | 8 |   |   |
|   | 2 |   | 6 |   | 9 |   | 5 |   |
|---+---+---+---+---+---+---+---+---|
| 8 |   |   |   | 9 |   |   |   | 5 |
|   | 1 |   | 4 |   | 3 |   | 8 |   |
| 2 |   | 4 |   |   |   | 1 |   | 9 |
#+CALL: export-sudoku(table=Test) :results output silent
#+CALL: import-sudoku() :hlines yes
--8<---------------cut here---------------end--------------->8---

One noteworthy thing: even though I say ":hlines no" (I can also do this
on the call line with the same result), the table still gets exported to
elisp _with_ hlines and I need to filter them out myself.  I'm not sure
if that is intended, but it feels a bit awkward.  If anything, this
exception should be noted in the documentation if it is intentional.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 20:33   ` Achim Gratz
@ 2013-01-07 20:54     ` Eric Schulte
  2013-01-07 21:36       ` Achim Gratz
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Schulte @ 2013-01-07 20:54 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

>
> One noteworthy thing: even though I say ":hlines no" (I can also do this
> on the call line with the same result), the table still gets exported to
> elisp _with_ hlines and I need to filter them out myself.  I'm not sure
> if that is intended, but it feels a bit awkward.  If anything, this
> exception should be noted in the documentation if it is intentional.
>

elisp is special in that no hline or heading processing is done for you
(the idea being that if you're working from within elisp you can do this
yourself).  This is a relic from the early days of Babel.  I believe it
is mentioned in the documentation (if it isn't I agree that it should
be).

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 20:54     ` Eric Schulte
@ 2013-01-07 21:36       ` Achim Gratz
  2013-01-08  6:38         ` Eric Schulte
  0 siblings, 1 reply; 11+ messages in thread
From: Achim Gratz @ 2013-01-07 21:36 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte writes:
> This is a relic from the early days of Babel.  I believe it is
> mentioned in the documentation (if it isn't I agree that it should
> be).

Not that I can find, neither in the manual nor Worg (I've looked again).


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-07 21:36       ` Achim Gratz
@ 2013-01-08  6:38         ` Eric Schulte
  2013-01-08 18:55           ` Achim Gratz
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Schulte @ 2013-01-08  6:38 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Achim Gratz <Stromeko@nexgo.de> writes:

> Eric Schulte writes:
>> This is a relic from the early days of Babel.  I believe it is
>> mentioned in the documentation (if it isn't I agree that it should
>> be).
>
> Not that I can find, neither in the manual nor Worg (I've looked again).
>

I added a note to the manual.  Thanks for double-checking.

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-08  6:38         ` Eric Schulte
@ 2013-01-08 18:55           ` Achim Gratz
  2013-01-09 17:22             ` Eric Schulte
  0 siblings, 1 reply; 11+ messages in thread
From: Achim Gratz @ 2013-01-08 18:55 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte writes:
> I added a note to the manual.  Thanks for double-checking.

Thanks.  Did I understand correctly that the same also happens for the
:rownames argument and should there be some similar wording like there
is for :colnames?


Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: simple script to convert txt tables to Org-mode tables on the command line
  2013-01-08 18:55           ` Achim Gratz
@ 2013-01-09 17:22             ` Eric Schulte
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Schulte @ 2013-01-09 17:22 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Achim Gratz <Stromeko@nexgo.de> writes:

> Eric Schulte writes:
>> I added a note to the manual.  Thanks for double-checking.
>
> Thanks.  Did I understand correctly that the same also happens for the
> :rownames argument

I just checked this and yes, elisp ignores :rownames as well.

> and should there be some similar wording like there is for :colnames?
>

Just committed such wording to the manual.

Thanks,

>
>
> Achim.

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-01-09 17:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 18:27 simple script to convert txt tables to Org-mode tables on the command line Eric Schulte
2013-01-07 18:37 ` Jambunathan K
2013-01-07 18:48   ` Eric Schulte
2013-01-07 18:54 ` Nick Dokos
2013-01-07 20:09 ` Bastien
2013-01-07 20:33   ` Achim Gratz
2013-01-07 20:54     ` Eric Schulte
2013-01-07 21:36       ` Achim Gratz
2013-01-08  6:38         ` Eric Schulte
2013-01-08 18:55           ` Achim Gratz
2013-01-09 17:22             ` Eric Schulte

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.