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.
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,john@example.com
Jane Smith,25,jane@example.com
foo@bar:~$ cat testdata/file2.csv | mdtable csv
|Name |Age |Email |
|---- |--- |----- |
|John Doe |30 |john@example.com |
|Jane Smith |25 |jane@example.com |
foo@bar:~$ cat testdata/file2.csv | mdtable csv -csv-no-header
|<!-- --> |<!-- --> |<!-- --> |
|-------- |-------- |-------- |
|Name |Age |Email |
|John Doe |30 |john@example.com |
|Jane Smith |25 |jane@example.com |
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>> |<<john@example.com>> |
|<<Jane Smith>> |<<25>> |<<jane@example.com>> |
go get moul.io/mdtable
See https://github.com/moul/mdtable/releases
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
Pre-commit script for install: https://pre-commit.com
Thanks goes to these wonderful people (emoji key):
Manfred Touron 🚧 📖 |
moul-bot 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!
© 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)