Golang clone of Python tabulate.
go get github.com/crackcell/gotabulate
package main
import "github.com/crackcell/gotabulate"
func main() {
tabulator := gotabulate.NewTabulator()
tabulator.SetFirstRowHeader(true)
tabulator.SetFormat("orgtbl")
fmt.Print(
tabulator.Tabulate(
[][]string{
[]string{"long long long id 1", "crackcell"},
[]string{"2", "crackcell2"},
[]string{"3", "crackcell3", "redundant cell"},
[]string{"4"},
[]string{"5", "crackcell5"}},
))
}
Output:
| long long long id 1 | crackcell |
|---------------------+------------|
| 2 | crackcell2 |
| 3 | crackcell3 |
| 4 | |
| 5 | crackcell5 |
not supported yet
- plain
- simple
- grid
fancy_grid- pipe
- psql
- orgtbl
rstmediawikihtmllatexlatex_booktabs
id name
------------------- ----------
long long long id 1 crackcell
2 crackcell2
3 crackcell3
4
5 crackcell5
id name age
long long long id 1 crackcell 27
2 crackcell2 27
3 crackcell3 27
4
5 crackcell5
+---------------------+------------+-----+
| id | name | age |
|---------------------+------------+-----|
| long long long id 1 | crackcell | 27 |
| 2 | crackcell2 | 27 |
| 3 | crackcell3 | 27 |
| 4 | | |
| 5 | crackcell5 | |
+---------------------+------------+-----+
| id | name |
|---------------------+------------|
| long long long id 1 | crackcell |
| 2 | crackcell2 |
| 3 | crackcell3 |
| 4 | |
| 5 | crackcell5 |
| id | name | age |
|:--------------------|-----------:|----:|
| long long long id 1 | crackcell | 27 |
| 2 | crackcell2 | 27 |
| 3 | crackcell3 | 27 |
| 4 | | |
| 5 | crackcell5 | |
+---------------------+------------+-----+
| id | name | age |
+=====================+============+=====+
| long long long id 1 | crackcell | 27 |
+---------------------+------------+-----+
| 2 | crackcell2 | 27 |
+---------------------+------------+-----+
| 3 | crackcell3 | 27 |
+---------------------+------------+-----+
| 4 | | |
+---------------------+------------+-----+
| 5 | crackcell5 | |
+---------------------+------------+-----+
- Menglong TAN tanmenglong@gmail.com
- Wenbin Xiao xwb1989@gmail.com