csvtable

package module
v0.0.0-...-2bfe148 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

README

= CSVTable

Pretty print CSV files as tables on the command line.

== Library

image:https://godoc.org/github.com/DavidGamba/csvtable?status.svg[link="http://godoc.org/github.com/DavidGamba/csvtable"]

Also provided as a library:

  import "github.com/DavidGamba/csvtable/lib/csvtable"

Documentation

Overview

Package csv-table provides a tool to view csv files on the cmdline.

┌──┬──┐
│  │  │
├──┼──┤
└──┴──┘

Index

Constants

This section is empty.

Variables

View Source
var Logger = log.New(ioutil.Discard, "csvtable DEBUG ", log.LstdFlags)

Logger - Default *log.Logger variable. Set output to os.Stderr or override.

Functions

func CSVRowIterator

func CSVRowIterator(reader io.Reader) <-chan Row

CSVRowIterator -

func FprintfTable

func FprintfTable(w io.Writer, config TableConfig, t Table, tableInfo TableInfo) error

FprintfTable -

func PrintCSVTable

func PrintCSVTable(r io.Reader) error

PrintCSVTable - Given an io.Reader that points to CSV content, it prints the CSV as a table.

func PrintSimpleTable

func PrintSimpleTable(data [][]string) error

PrintSimpleTable -

func SimpleRowIterator

func SimpleRowIterator(data [][]string) <-chan Row

SimpleRowIterator -

Types

type CSVTable

type CSVTable struct {
	Reader io.Reader
}

CSVTable -

func (CSVTable) RowIterator

func (t CSVTable) RowIterator() <-chan Row

RowIterator - Implements the Table interface.

type Row

type Row struct {
	Data  []string
	Error error
}

Row - Data and Error struct

type SimpleTable

type SimpleTable struct {
	Data [][]string
}

SimpleTable - A basic structure that implements the Table interface.

func (SimpleTable) RowIterator

func (t SimpleTable) RowIterator() <-chan Row

RowIterator - Implements the Table interface.

type Table

type Table interface {
	RowIterator() <-chan Row
}

Table - interface used to print a table

type TableConfig

type TableConfig struct {
	HeaderStart     string
	HeaderEnd       string
	HeaderJuncture  string
	Body            string
	Column          string
	LineStart       string
	LineEnd         string
	LineJuncture    string
	LineBetweenRows bool
	ColumnEdges     bool
}

TableConfig -

func NewDefaultTableConfig

func NewDefaultTableConfig(columnEdges, lineBetweenRows bool) TableConfig

NewDefaultTableConfig -

type TableInfo

type TableInfo struct {
	Columns            int
	Rows               int
	PerRowColumnWidths [][]int
	// Number of Lines in a Row due to multiline entries.
	PerRowRows   [][]int
	ColumnWidths []int
	RowHeights   []int
}

TableInfo - Table information

func GetTableInfo

func GetTableInfo(t Table) (TableInfo, error)

GetTableInfo - Iterates over all the elements of the table to get number of Colums, Colum widths, etc.

func (TableInfo) String

func (i TableInfo) String() string

Directories

Path Synopsis
cmd
csvtable
Package csv-table provides a tool to view csv files on the cmdline.
Package csv-table provides a tool to view csv files on the cmdline.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL