Skip to content

Latest commit

 

History

History
130 lines (96 loc) · 5.72 KB

README.md

File metadata and controls

130 lines (96 loc) · 5.72 KB

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.

go.dev reference License GitHub release Docker Metrics Made by Manfred Touron

Go Release PR GolangCI codecov Go Report Card CodeFactor

Gitpod ready-to-code

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

Contribute <3

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 ✨

All Contributors

Thanks goes to these wonderful people (emoji key):


Manfred Touron

🚧 📖 ⚠️ 💻

moul-bot

🚧

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

Stargazers over time

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)