3

I'm using Org-mode is the log-book for my agricultural field trials and my Phd thesis in general.

Reporting field trials I would like to export the agenda views of trials to org-tables to get something like this as a final product: (Toy data)

| Trial   | Date   (Toy data) | Action                | DAE |
|---------+-------------------+-----------------------+-----|
| Trial A | <2013-02-21 Thu>  | Planting              |     |
| Trial A | <2013-03-03 Sun>  | Emergence             |  0  |
| Trial A | <2013-04-19 Fri>  | Fungicide Application |  7  |
| Trial A | <2013-05-20 Mon>  | Biomass Evaluation    |  50 |
| Trial A | <2013-06-21 Fri>  | Harvest               | 110 |
| Trial B | ...               | ...                   |     |
| ...     | ...               | ...                   |     |

From the C-a m (TAG search) I can get something like this here (real data):

  13pgSoja:   13pgSoja: Planting: Soybean <2012-11-06 Tue>        :NPW:2013:PG::
  13pgSoja:   13pgSoja: Emergence <2012-11-14 Thu>                :NPW:2013:PG::
  13pgSoja:   13pgSoja: Application 1 <2012-11-22 Thu 14:30-16:30> :NPW:2013:PG::
  13pgSoja:   13pgSoja: Evaluation: Control 1 <2012-11-28 Wed>    :NPW:2013:PG::
  13pgSoja:   13pgSoja: Evaluation: Biomass Weeds <2013-02-18 Mon> :NPW:2013:PG::
  13pgSoja:   13pgSoja: Evaluation: Biomass Soybean               :NPW:2013:PG::
  13pgSoja:   13pgSoja: Harvest <2013-03-25 Mon>                  :NPW:2013:PG::

Editing away unnecessary tags is not a problem, I get: (I added the header for the three first columns just to make clear my idea...)

Trial        Action                Date     
  13pgSoja: Planting: Soybean <2012-11-06 Tue>        
  13pgSoja: Emergence <2012-11-14 Thu>                
  13pgSoja: Application 1 <2012-11-22 Thu 14:30-16:30> 
  13pgSoja: Evaluation: Control 1 <2012-11-28 Wed>    
  13pgSoja: Evaluation: Biomass Weeds <2013-02-18 Mon> 
  13pgSoja: Evaluation: Biomass Soybean               
  13pgSoja: Harvest <2013-03-25 Mon>                  

Then converting this format to an org-table:

| Trial     | Action                      | Date             | DAE |
| 13pgSoja: | Planting: Soybean           | <2012-11-06 Tue> |     |
| 13pgSoja: | Emergence                   | <2012-11-14 Thu> |   0 |
| 13pgSoja: | Application 1               | <2012-11-22 Thu> |     |
| 13pgSoja: | Evaluation: Control 1       | <2012-11-28 Wed> |     |
| 13pgSoja: | Evaluation: Biomass Weeds   | <2013-02-18 Mon> |     |
| 13pgSoja: | Evaluation: Biomass Soybean | <2013-02-18 Mon> |     |
| 13pgSoja: | Harvest                     | <2013-03-25 Mon> | 130 |

The DAE stands for "Days after emergence". I would like to be able to calculate the "crop age" from the dates and sorting by date. Is the format from the agenda any good for calculations? This is actually an additional question...

Converting data to a table is a problem (converting without header, that I would add later). I would have to do the seperations all manually. Is there any easy way to export the agenda view into an org-table form? Is column view of org-agenda the right path?

3
  • It's hard to see how the the tags you have relate to the table. I see data in the table that I don't see in the tags. Would you be able to provide small portion of data, and a equivalent table? – Alex McKenzie Apr 25 '14 at 19:09
  • Here you go Alex; added some more data and desired output table – mcg Apr 25 '14 at 20:57
  • Don't really see the required transformation, but awk is your friend (along with cut). By default, awk reads each line of an input file, splits it into fields using the delimiters or fixed length fields of your choice and then matches each line against successive patterns (that you specify). When a pattern matches, then the action associated with that pattern is invoked. It's perfect for restructuring and cleaning data. – Joe May 6 '14 at 6:13
1

I actually found a solution to my problem on the org-mode help pages. The links are http://orgmode.org/manual/Scope-of-column-definitions.html and http://orgmode.org/manual/Capturing-column-view.html.

Org column view as such is not exportable, but can be captured using dynamic blocks:

Example data:

* Trial A

** Planting
<2014-02-28 Fri>
** Emergence
<2014-03-10 Mon>
** Biomass evaluation
<2014-04-29 Tue>
** Harvest
<2014-05-28 Wed>

I wanted the item itself (%25ITEM) and the date (%TIMESTAMP) exported, so I set:

#+COLUMNS: %25ITEM %TIMESTAMP

Then one goes to the top header (Trial A) and uses: 

C-c C-x i  --- (org-insert-columns-dblock) ; I get


#+BEGIN: columnview :hlines 1 :id local
| ITEM                  | TIMESTAMP      |   |
|-----------------------+----------------+---|
| * Trial A             |                |   |
| ** Planting           | 2014-02-28 Fri |   |
| ** Emergence          | 2014-03-10 Mon |   |
| ** Biomass evaluation | 2014-04-29 Tue |   |
| ** Harvest            | 2014-05-28 Wed |   |
#+END:

(I added a third column) This I can easily be changed to the output I wanted (eliminating stars + changing headers). Adding a third column I can do the date calculations I want as well, with :

#+TBLFM: $3 = date(<$2>) - date(<2012-10-21>)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.