-
Notifications
You must be signed in to change notification settings - Fork 380
[v1.0.5-pre] How to disable headers? #255
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
Comments
Hi @zx8 , Will help you add tablewriter/tests/basic_test.go Lines 530 to 580 in 0fd7b11
Hope this helps ? |
package main
import (
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
"os"
)
type Age int
func (a Age) String() string {
return fmt.Sprintf("%d yrs", a)
}
func main() {
data := [][]any{
{"Name", "Age", "City"},
{"Alice", Age(25), "New York"},
{"Bob", Age(30), "Boston"},
}
table := tablewriter.NewTable(
os.Stdout,
tablewriter.WithPadding(tw.Padding{
Left: "*",
Right: "#",
Top: "",
Bottom: "",
}),
)
table.Header(data[0])
table.Bulk(data[1:])
table.Render()
}
|
Sorry, I wanted to disable the header entirely as well, if that's possible? So rather than:
I wanted:
|
just comment out the header package main
import (
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
"os"
)
type Age int
func (a Age) String() string {
return fmt.Sprintf("%d yrs", a)
}
func main() {
data := [][]any{
{"Name", "Age", "City"},
{"Alice", Age(25), "New York"},
{"Bob", Age(30), "Boston"},
}
table := tablewriter.NewTable(
os.Stdout,
tablewriter.WithPadding(tw.Padding{
Left: "*",
Right: "#",
Top: "",
Bottom: "",
}),
)
/// table.Header(data[0])
table.Bulk(data[1:])
table.Render()
}
However, if I understand your use case correctly, I may be able to add a configuration ... help me out. |
Sure, I am loading a CSV like: r := csv.NewReader(os.Stdin)
table, err := tablewriter.NewCSVReader(os.Stdout, r, true)
if err != nil {
return err
}
table.Render() The input data has a header, but I want to skip it when rendering the table. |
Understandable will add support for this so you can do package main
import (
"encoding/csv"
"github.com/olekukonko/ll"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
"os"
"strings"
)
const csvTestData = `Name,Department,Salary
Alice,Engineering,120000
Bob,Marketing,85000
Charlie,Engineering,135000
Diana,HR,70000
`
func main() {
r := csv.NewReader(strings.NewReader(csvTestData))
table, err := tablewriter.NewCSVReader(os.Stdout, r, true,
tablewriter.WithDebug(true),
tablewriter.WithHeaderControl(tw.Control{Hide: tw.On}),
)
if err != nil {
ll.Fatal(err)
}
table.Render()
}
|
I'm trying to match my v0.0.5 configuration using the latest commit 88e7330 so I can prove feedback before the release. I've managed to discover the majority of settings, but the two I can't seem to find the equivalents of are:
Also, another suggestion (to save me raising a separate issue) since
tw.BorderNone
already exists as a convenient helper, could you also add:and
The text was updated successfully, but these errors were encountered: