3
$\begingroup$

Is there a way automatically/programmatically convert an org-mode table

| Name  | Start Date       | End Date         | Notes            |
|-------+------------------+------------------+------------------|
| Name1 | [2018-12-19 Wed] | [2019-12-19 Thu] | Some notes.      |
| Name2 | [2016-12-19 Wed] | [2018-12-19 Thu] | Some more notes. |

to its corresponding Wolfram datastructure? Perhaps something like

data = {Labeled[Interval[{DateObject[{2018,12,19}], DateObject[{2019,12,19}]}], "Name1: Some notes."], Labeled[Interval[{DateObject[{2016,12,19}], DateObject[{2018,12,19}]}], "Name2: Some more notes."]}

which can be used like

TimelinePlot[data]

$\endgroup$
1
  • $\begingroup$ Good question. I would like to mention that org-tables can be exported to CSV files, and those CSV files can be ingested in Mathematica. $\endgroup$ Dec 20, 2019 at 13:15

1 Answer 1

3
$\begingroup$

If your org-mode table is in a plain text file, this approach should work

org = ReadList["orgmode.txt", String];

a = StringSplit[org[[3 ;;]], "|"];
b = a /. s_String :> StringTrim[s];
c = b /. s_String :>
   StringReplace[s, "[" ~~ ymd__ ~~ " " ~~ __ ~~ "]" :> ymd]

data = Labeled[
     Interval[ { DateObject[#[[2]]], DateObject[#[[3]]] } ],
     #[[1]] <> ": " <> #[[4]]  ]& /@ c;

TimelinePlot[data]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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