emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Export properties as (csv) table


From: Nick Dokos
Subject: Re: [O] Export properties as (csv) table
Date: Tue, 04 Sep 2012 15:26:21 -0400

Bernd Weiss <address@hidden> wrote:

> Dear all,
> 
> Let's say I have the following entries and their associated
> properties. Is there an easy way to export these information as csv
> formated table?
> 
> * Marc, Mart                                         :Mart_Marc::
>     :PROPERTIES:
>     :name: Marc, Mart
>     :typ: diss
>     :empirisch: ja
>     :status: angemeldet
>     :END:
> * Marc, Mart2                                        :Mart_Marc2:
>     :PROPERTIES:
>     :name: Marc, Mart2
>     :typ: diss
>     :empirisch: ja
>     :status: angemeldet
>     :END:
> 
> The final csv table would look like this:
> 
> name, typ, empirisch, status
> Mart, Marc; diss; ja; angemeldet
> Mart2, Marc; diss; ja; angemeldet
> 
> 
> I played around with dynamic blocks and spent some time trying to
> understand the property API but since my elips skills are very (very)
> limited to no avail...
> 

Perhaps a combination of a columnview dblock[fn:1] to produce a table and then
a radio table with a translation function[fn:2]:

--8<---------------cut here---------------start------------->8---
#+COLUMNS: %name %typ %empirisch %status
* Marc, Mart                                           :Mart_Marc::
    :PROPERTIES:
    :name: Marc, Mart
    :typ: diss
    :empirisch: ja
    :status: angemeldet
    :END:
* Marc, Mart2                                          :Mart_Marc2:
    :PROPERTIES:
    :name: Marc, Mart2
    :typ: diss
    :empirisch: nein
    :status: angemeldet
    :END:

* The column view
#+ORGTBL: SEND foo orgtbl-to-csv
     #+BEGIN: columnview :hlines 1 :id global
     #+END:

#+BEGIN_EXAMPLE
BEGIN RECEIVE ORGTBL foo
END RECEIVE ORGTBL foo
#+END_EXAMPLE
--8<---------------cut here---------------end--------------->8---

C-c C-c on the columnview dblock will create a table from the properties
using the COLUMNS definition:

--8<---------------cut here---------------start------------->8---
* The column view
#+ORGTBL: SEND foo orgtbl-to-csv
     #+BEGIN: columnview :hlines 1 :id global
     | name        | typ  | empirisch | status     |
     |-------------+------+-----------+------------|
     | Marc, Mart  | diss | ja        | angemeldet |
     | Marc, Mart2 | diss | nein      | angemeldet |
     |             |      |           |            |
     #+END:
--8<---------------cut here---------------end--------------->8---

In order to accomplish the radio-table sending part, I had to switch
the ORGTBL and BEGIN lines, otherwise the sending is not activated.
This might qualify as a bug. So it looks like this:

--8<---------------cut here---------------start------------->8---
* The column view
     #+BEGIN: columnview :hlines 1 :id global
#+ORGTBL: SEND foo orgtbl-to-csv
     | name        | typ  | empirisch | status     |
     |-------------+------+-----------+------------|
     | Marc, Mart  | diss | ja        | angemeldet |
     | Marc, Mart2 | diss | nein      | angemeldet |
     |             |      |           |            |
     #+END:
--8<---------------cut here---------------end--------------->8---

Then C-c C-c in the table sends it to the target:

--8<---------------cut here---------------start------------->8---
* The column view
     #+BEGIN: columnview :hlines 1 :id global
#+ORGTBL: SEND foo orgtbl-to-csv
     | name        | typ  | empirisch | status     |
     |-------------+------+-----------+------------|
     | Marc, Mart  | diss | ja        | angemeldet |
     | Marc, Mart2 | diss | nein      | angemeldet |
     |             |      |           |            |
     #+END:

#+BEGIN_EXAMPLE
BEGIN RECEIVE ORGTBL foo
name,typ,empirisch,status
"Marc, Mart",diss,ja,angemeldet
"Marc, Mart2",diss,nein,angemeldet
,,,
END RECEIVE ORGTBL foo
#+END_EXAMPLE
--8<---------------cut here---------------end--------------->8---


Nick

Footnotes:

[fn:1] (info "(org) Capturing column view")

[fn:2] (info "(org) Tables in arbitrary syntax")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]