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

feature request: csv2html #132

Open
4 tasks done
tseemann opened this issue Feb 18, 2021 · 2 comments
Open
4 tasks done

feature request: csv2html #132

tseemann opened this issue Feb 18, 2021 · 2 comments

Comments

@tseemann
Copy link

tseemann commented Feb 18, 2021

Prerequisites

  • make sure you're are using the latest version by csvtk version
  • read the usage

Describe your issue

  • describe the problem
  • provide a reproducible example

csvtk csv2html

This subcommand would make an HTML table to modern spec.

<TABLE>
<THEAD>
<TR> <TH> ID <TH> value <TH> meta </TR>
</THEAD>
<TBODY>
<TR><TD> covid <TD> 2020<TD> bad </TR>
<TR><TD> sars <TD> 2021<TD> worse </TR>
<TR><TD> flu <TD> 2022<TD> ok </TR>
</TBODY>
</TABKE>

Maybe options to set the HTML CSS Class
<TABLE CLASS="xxxxx">

And the caption
<CAPTION> xxxxxxxxxxx </CAPTION>

@shenwei356
Copy link
Owner

shenwei356 commented Feb 18, 2021

It's not complicated but existed tools like pandoc can easily convert markdown to HTML, though there are no options to set table class and caption.

$ cat names.csv | csvtk csv2md | pandoc 
<table>
<thead>
<tr class="header">
<th style="text-align: left;">id</th>
<th style="text-align: left;">first_name</th>
<th style="text-align: left;">last_name</th>
<th style="text-align: left;">username</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">11</td>
<td style="text-align: left;">Rob</td>
<td style="text-align: left;">Pike</td>
<td style="text-align: left;">rob</td>
</tr>
<tr class="even">
<td style="text-align: left;">2</td>
<td style="text-align: left;">Ken</td>
<td style="text-align: left;">Thompson</td>
<td style="text-align: left;">ken</td>
</tr>
<tr class="odd">
<td style="text-align: left;">4</td>
<td style="text-align: left;">Robert</td>
<td style="text-align: left;">Griesemer</td>
<td style="text-align: left;">gri</td>
</tr>
<tr class="even">
<td style="text-align: left;">1</td>
<td style="text-align: left;">Robert</td>
<td style="text-align: left;">Thompson</td>
<td style="text-align: left;">abc</td>
</tr>
<tr class="odd">
<td style="text-align: left;">NA</td>
<td style="text-align: left;">Robert</td>
<td style="text-align: left;">Abel</td>
<td style="text-align: left;">123</td>
</tr>
</tbody>
</table>

id first_name last_name username
11 Rob Pike rob
2 Ken Thompson ken
4 Robert Griesemer gri
1 Robert Thompson abc
NA Robert Abel 123

@shenwei356 shenwei356 changed the title feature request: csv2htnkl feature request: csv2html Feb 18, 2021
@tseemann
Copy link
Author

There are existing tools to do CSV to MD and JSON too, but you implemented those :-)

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

No branches or pull requests

2 participants