exporting tables (ascii or LaTeX)

415 views
Skip to first unread message

Tamas Papp

unread,
Feb 28, 2015, 4:52:13 AM2/28/15
to Julia Users
Hi,

I am solving some economic models in Julia. I have vectors that describe
various moments, for some data and then for a bunch of models. I would
like to export them to LaTeX, and if possible to ASCCI like org-mode.

| moment | data | model1 | model2 | ... |
|----------+------+--------+--------+-----|
| UE / 1m | 0.37 | 0.37 | 0.37 | |
| UE / 12m | 0.59 | 0.90 | 0.89 | |
| ... | | | | |

I found LaTeX.jl, I am wondering if anyone can suggest another solution,
especially for the ASCII tables. Dumping in some format that Julia can
export to, then converting with some external tool would not be a
problem, especially since I could automate the whole thing from Julia.

Best,

Tamas

Devendra Ghate

unread,
Feb 28, 2015, 8:03:45 AM2/28/15
to julia...@googlegroups.com
Dear Tamas,

I am using `writedlm` followed by conversion to `markdown` and `html` using
`pandoc` for now. However, since there are no methods for specifying the
float format in `writedlm`, I couldn't find a way to make the solution
look pretty (expect using C `printf`).

Markdown tables from pandoc look pretty similar to the one you have
shown.

Devendra
--
Devendra Ghate

j verzani

unread,
Feb 28, 2015, 11:34:36 PM2/28/15
to julia...@googlegroups.com
For a simple solution, you might try Mustache which can iterate over a data frame. Something like this could be generalized:

using Mustache
using DataFrames
d = DataFrame(a=1:10, b=rand(10))
d[:b] = round(d[:b],2)
tpl="""
\\begin{table}
  \\centering
  \\begin{tabular}{cc}
    {{#df}}{{a}}&{{b}}\\\\{{/df}}
  \\end{tabular}
  \\caption{ {{caption}} }
  \\label{tab:{{label}}}
\\end{table}
"""

render(tpl, ["df"=>d, "caption"=>"caption", "label" => "label"]) |> print

René Donner

unread,
Mar 2, 2015, 9:43:19 AM3/2/15
to julia...@googlegroups.com
I have to tried it myself yet, but did you see https://github.com/scheinerman/LatexPrint.jl?

Tamas Papp

unread,
Mar 2, 2015, 9:47:01 AM3/2/15
to julia...@googlegroups.com
Thanks for the link -- I was not aware of this, so I wrote my own
library which can print as org-mode, Markdown, and some other
formats. Will make it public soon, I am finalizing the interface now.

Best,

Tamas

Brett Israelsen

unread,
Sep 6, 2016, 4:15:06 PM9/6/16
to julia-users
Has this library been made public? I would be interested in using it. Thanks!
Reply all
Reply to author
Forward
0 new messages