mdtable

csv/json to markdown tables with customizable format

OTHER License

Stars
2
Committers
3

mdtable

This Go program converts a CSV/JSON file into a Markdown table using a configurable format string. It leverages the power of the tabwriter and text/template packages to generate neatly formatted tables from CSV/JSON data.

Usage

foo@bar:~$ mdtable
USAGE
  mdtable csv [flags]

FLAGS
  -csv-no-header false                      csv: no header, just body
  -md-body {{range .Cols}}{{.}}\t{{end}}    mdtable body format
  -md-header {{range .Cols}}{{.}}\t{{end}}  mdtable header format
exit status 1
foo@bar:~$ cat testdata/file2.csv
Name,Age,Email
John Doe,30,[email protected]
Jane Smith,25,[email protected]

foo@bar:~$ cat testdata/file2.csv | mdtable csv
|Name       |Age |Email            |
|----       |--- |-----            |
|John Doe   |30  |[email protected] |
|Jane Smith |25  |[email protected] |

foo@bar:~$ cat testdata/file2.csv | mdtable csv -csv-no-header
|<!-- -->   |<!-- --> |<!-- -->         |
|--------   |-------- |--------         |
|Name       |Age      |Email            |
|John Doe   |30       |[email protected] |
|Jane Smith |25       |[email protected] |

foo@bar:~$ cat testdata/file2.csv | mdtable csv -md-header="foo\tbar\tbaz\t" -md-body="{{range .Cols}}<<{{.}}>>\t{{end}}"
|foo            |bar    |baz                  |
|---            |---    |---                  |
|<<John Doe>>   |<<30>> |<<[email protected]>> |
|<<Jane Smith>> |<<25>> |<<[email protected]>> |

Install

Using go

go get moul.io/mdtable

Releases

See https://github.com/moul/mdtable/releases

Contribute

I really welcome contributions. Your input is the most precious material. I'm well aware of that and I thank you in advance. Everyone is encouraged to look at what they can do on their own scale; no effort is too small.

Everything on contribution is sum up here: CONTRIBUTING.md

Dev helpers

Pre-commit script for install: https://pre-commit.com

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Stargazers over time

License

ยฉ 2021-2023 Manfred Touron

Licensed under the Apache License, Version 2.0 (LICENSE-APACHE) or the MIT license (LICENSE-MIT), at your option. See the COPYRIGHT file for more details.

SPDX-License-Identifier: (Apache-2.0 OR MIT)