Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown display #1167

Closed
yakir12 opened this issue Feb 21, 2017 · 14 comments
Closed

Markdown display #1167

yakir12 opened this issue Feb 21, 2017 · 14 comments

Comments

@yakir12
Copy link
Contributor

yakir12 commented Feb 21, 2017

It would be useful if writetable had an option to save the table as a markdown table (the repl output seems to already be in markdown).

@ExpandingMan
Copy link
Contributor

+1 for this, or, better yet, a LaTeX tabular. I think I/O functionality either has been or will be moved to another package though, so I'm not sure whether this is still the appropriate place for issues like this.

@nalimilan
Copy link
Member

writetable is meant to write CSV files, and it's going to be deprecated in favor of CSV.jl anyway. Markdown output should rather go through the show machinery, just like we currently do for HTML and LaTeX (in DataTables only, see this file).

@nalimilan nalimilan changed the title markdown writetable Markdown display Feb 21, 2017
@ExpandingMan
Copy link
Contributor

I wasn't aware the LaTeX output functionality existed, that is very cool indeed!

@quinnj
Copy link
Member

quinnj commented Feb 21, 2017

It would actually be pretty easy to write a MarkdownTables.jl package that implemented the DataStreams interface. Then you read/write a markdown table from any other DataStream package.

@yakir12
Copy link
Contributor Author

yakir12 commented Feb 22, 2017

I agree that this functionality doesn't need to live in DataFrames. Markdown.jl lives in Base, and therefore it should be slim (right?), but there could be many other functionalities that become relevant for such a package. I'm mainly thinking of use-cases involving pandoc, where you'd parse some data you have in julia (e.g. as a DataFrame) to markdown, and then use pandoc to convert that into whatever you want (LaTeX, HTML, etc).

@korsbo
Copy link

korsbo commented Jan 21, 2019

It is possible to generate both markdown and LaTeX tables from a DataFrame using Latexify.jl. If you feel that Latexify is not doing a sufficiently good job of this, then feel free to post an issue there (or submit a PR).

@bkamins
Copy link
Member

bkamins commented Jul 25, 2019

I think this should be a generic functionality for any type that supports Tables.jl API so it is probably outside DataFrames.jl so I am closing this (feel free to reopen if you think we should discuss it more here).

@bkamins bkamins closed this as completed Jul 25, 2019
@nalimilan
Copy link
Member

Given that the code for that should be pretty simple (basically like CSV), it wouldn't be absurd to support that in DataFrames.jl if somebody wants to make a PR. If we want to put this in a separate package, better have a single package taking any table in the Tables.jl sense and supporting a variety of MIME types. Then DataFrames could use it to implement show(io, mime, df).

@pgagarinov
Copy link

@bkamins

Documentation for show says:
image

However, passing tf=tf_format into show doesn't seem to work:

image

And I have to call pretty_table directly to make it work:
image

Is ignoring tf kwarg the expected behavior?

@bkamins
Copy link
Member

bkamins commented Apr 13, 2021

@ronisbr - could you please comment here? Maybe we need to update the docstring? Thank you!

@bkamins
Copy link
Member

bkamins commented Apr 13, 2021

Also here is what I get:

julia> using DataFrames

julia> show(DataFrame(a=1:3,b='x':'z'), tf=PrettyTables.tf_markdown)
3×2 DataFrame
 Row | a      b    
     | Int64  Char 
-----|-------------
   1 |     1  x
   2 |     2  y
   3 |     3  z
julia> PrettyTables.pretty_table(DataFrame(a=1:3,b='x':'z'), tf=PrettyTables.tf_markdown)
|     a |    b |
| Int64 | Char |
|-------|------|
|     1 |    x |
|     2 |    y |
|     3 |    z |

(and maybe this is what is expected?)

@ronisbr
Copy link
Member

ronisbr commented Apr 13, 2021

It is doing what it is supposed to. The problem is that the other configurations in DataFrames hide vertical lines. Hence, in this case, you will also need to pass vlines = :all.

@bkamins
Copy link
Member

bkamins commented Apr 13, 2021

Thank you (this is what I assumed, but unfortunately I have not mastered all options of PrettyTables.jl yet)

@ronisbr
Copy link
Member

ronisbr commented Apr 13, 2021

No problem! Feel free to ping me in every issue related to PrettyTables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants