Documentation ¶
Index ¶
- Variables
- type Body
- type Column
- type FTime
- type Filterer
- type Format
- type Generator
- type Header
- type Mapper
- type Reducer
- type Row
- type Table
- func (t *Table) Append(r ...Row) *Table
- func (t *Table) AppendCol(colName string, c Column) *Table
- func (t *Table) Bool(i, j int) bool
- func (t *Table) Col(j int) Column
- func (t *Table) ColBools(j int) []bool
- func (t *Table) ColFloats(j int) []float64
- func (t *Table) ColInts(j int) []int
- func (t *Table) ColStrs(j int) []string
- func (t *Table) ColTimes(j int) []time.Time
- func (t *Table) ColType(j int) Type
- func (t *Table) ColTypes() Types
- func (t *Table) Copy() *Table
- func (t *Table) Dims() (int, int)
- func (t *Table) Equal(tbl *Table) bool
- func (t *Table) Filter(f Filterer) *Table
- func (t *Table) Float(i, j int) float64
- func (t *Table) Format(fmt Format) string
- func (t *Table) Header() Header
- func (t *Table) Insert(i int, r Row) *Table
- func (t *Table) InsertCol(j int, colName string, c Column) *Table
- func (t *Table) Int(i, j int) int
- func (t *Table) JSON() string
- func (t *Table) Map(f Mapper) *Table
- func (t *Table) MarshalJSON() ([]byte, error)
- func (t *Table) Reduce(f Reducer) Row
- func (t *Table) Remove(i int) Row
- func (t *Table) RemoveCol(j int) (string, Column)
- func (t *Table) Row(i int) Row
- func (t *Table) Rows() []Row
- func (t *Table) Set(i, j int, v interface{}) *Table
- func (t *Table) SetColName(j int, s string) *Table
- func (t *Table) SetHeader(h Header) *Table
- func (t *Table) Sort(j int) *Table
- func (t *Table) Stable(j int) *Table
- func (t *Table) Str(i, j int) string
- func (t *Table) String() string
- func (t *Table) Strings() [][]string
- func (t *Table) Swap(i, j int) *Table
- func (t *Table) SwapCols(i, j int) *Table
- func (t *Table) Time(i, j int) time.Time
- func (t *Table) UnmarshalJSON(b []byte) error
- func (t *Table) Validate() error
- func (t *Table) Value(i, j int) interface{}
- func (t *Table) WriteCSV(file string) error
- type Type
- type Types
Constants ¶
This section is empty.
Variables ¶
var ( // Fmt0 ... // Int Str // ---------- // 0 a // 1 b // 2 c Fmt0 = Format{ UpperHoriz: "", UpperLeftHorizDelim: "", UpperMidHorizDelim: "", UpperRightHorizDelim: "", MiddleHoriz: "-", MiddleLeftHorizDelim: "", MiddleMidHorizDelim: "", MiddleRightHorizDelim: "", BottomHoriz: "", BottomLeftHorizDelim: "", BottomMidHorizDelim: "", BottomRightHorizDelim: "", HeaderLeftDelim: "", HeaderMidDelim: "", HeaderRightDelim: "", RowLeftDelim: "", RowMidDelim: "", RowRightDelim: "", } // Fmt1 ... // ---------- // Int Str // ---------- // 0 a // 1 b // 2 c Fmt1 = Format{ UpperHoriz: "-", UpperLeftHorizDelim: "", UpperMidHorizDelim: "", UpperRightHorizDelim: "", MiddleHoriz: "-", MiddleLeftHorizDelim: "", MiddleMidHorizDelim: "", MiddleRightHorizDelim: "", BottomHoriz: "", BottomLeftHorizDelim: "", BottomMidHorizDelim: "", BottomRightHorizDelim: "", HeaderLeftDelim: "", HeaderMidDelim: "", HeaderRightDelim: "", RowLeftDelim: "", RowMidDelim: "", RowRightDelim: "", } // Fmt2 ... // Int Str // ----------- // 0 a // 1 b // 2 c // ----------- Fmt2 = Format{ UpperHoriz: "", UpperLeftHorizDelim: "", UpperMidHorizDelim: "", UpperRightHorizDelim: "", MiddleHoriz: "-", MiddleLeftHorizDelim: "", MiddleMidHorizDelim: "", MiddleRightHorizDelim: "", BottomHoriz: "-", BottomLeftHorizDelim: "", BottomMidHorizDelim: "", BottomRightHorizDelim: "", HeaderLeftDelim: "", HeaderMidDelim: "", HeaderRightDelim: "", RowLeftDelim: "", RowMidDelim: "", RowRightDelim: "", } // Fmt3 ... // ---------- // Int Str // ---------- // 0 a // 1 b // 2 c // ---------- Fmt3 = Format{ UpperHoriz: "-", UpperLeftHorizDelim: "", UpperMidHorizDelim: "", UpperRightHorizDelim: "", MiddleHoriz: "-", MiddleLeftHorizDelim: "", MiddleMidHorizDelim: "", MiddleRightHorizDelim: "", BottomHoriz: "-", BottomLeftHorizDelim: "", BottomMidHorizDelim: "", BottomRightHorizDelim: "", HeaderLeftDelim: "", HeaderMidDelim: "", HeaderRightDelim: "", RowLeftDelim: "", RowMidDelim: "", RowRightDelim: "", } // Fmt4 ... // Int Str // ----- ----- // 0 a // 1 b // 2 c Fmt4 = Format{ UpperHoriz: "", UpperLeftHorizDelim: "", UpperMidHorizDelim: "", UpperRightHorizDelim: "", MiddleHoriz: "-", MiddleLeftHorizDelim: "", MiddleMidHorizDelim: " ", MiddleRightHorizDelim: "", BottomHoriz: "", BottomLeftHorizDelim: "", BottomMidHorizDelim: "", BottomRightHorizDelim: "", HeaderLeftDelim: "", HeaderMidDelim: " ", HeaderRightDelim: "", RowLeftDelim: "", RowMidDelim: " ", RowRightDelim: "", } // Fmt5 ... // +-----+-----+ // | Int | Str | // +-----+-----+ // | 0 | a | // | 1 | b | // | 2 | c | // +-----+-----+ Fmt5 = Format{ UpperHoriz: "-", UpperLeftHorizDelim: "+", UpperMidHorizDelim: "+", UpperRightHorizDelim: "+", MiddleHoriz: "-", MiddleLeftHorizDelim: "+", MiddleMidHorizDelim: "+", MiddleRightHorizDelim: "+", BottomHoriz: "-", BottomLeftHorizDelim: "+", BottomMidHorizDelim: "+", BottomRightHorizDelim: "+", HeaderLeftDelim: "|", HeaderMidDelim: "|", HeaderRightDelim: "|", RowLeftDelim: "|", RowMidDelim: "|", RowRightDelim: "|", } )
Functions ¶
This section is empty.
Types ¶
type Body ¶
type Body []interface{}
Body is a list of mn values.
type Column ¶
type Column []interface{}
Column is a list of values.
type FTime ¶
type FTime struct {
// contains filtered or unexported fields
}
FTime is a time.Time together with a format that was either used in parsing the timestamp from a string or set to format the timestamp.
func NewFTime ¶
NewFTime returns a new FTime. A single format may be passed indicating how the underlying time.Time will be formatted when writing to string. This panics if more than one format is provided. If no format is provided, time.RFC3339Nano is set as the format by default.
func ParseFTime ¶
ParseFTime returns a new FTime parsed from the default time formats and any additional time formats.
type Format ¶ added in v1.1.0
type Format struct { UpperHoriz string UpperLeftHorizDelim string UpperMidHorizDelim string UpperRightHorizDelim string MiddleHoriz string MiddleLeftHorizDelim string MiddleMidHorizDelim string MiddleRightHorizDelim string BottomHoriz string BottomLeftHorizDelim string BottomMidHorizDelim string BottomRightHorizDelim string HeaderLeftDelim string HeaderMidDelim string HeaderRightDelim string RowLeftDelim string RowMidDelim string RowRightDelim string }
Format holds decoration characters for displaying a table.
type Header ¶
type Header []string
Header is a list of column names.
type Reducer ¶
type Reducer func(dst, src Row)
Reducer combines two rows into one. Only the destination row should be mutated.
type Row ¶
type Row []interface{}
Row is a list of values.
func (Row) Interfaces ¶
func (r Row) Interfaces() []interface{}
Interfaces returns a list of values in a row.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
A Table holds tabular data.
func FromJSON ¶
FromJSON returns a new table with data parsed from a json-encoded string. This string should adhere to the following format.
{"header":["", ...],"types":[0, ...],"body":["", ...]}
func (*Table) ColFloats ¶ added in v1.1.0
ColFloats returns the jth column with each value cast as a float.
func (*Table) Filter ¶
Filter applies a filterer on each row. Each row in which f evaluates as true is retained; all other rows are discarded.
func (*Table) MarshalJSON ¶
MarshalJSON returns a list of json-encoded bytes. This implements the json.Marshaller interface.
func (*Table) Reduce ¶
Reduce returns a row that is the product of applying a reducer on each row in a table. A copy of the first row is used as the accumulator.
func (*Table) SetColName ¶ added in v1.1.0
SetColName sets the jth column name.
func (*Table) Strings ¶
Strings returns a list of string lists. The first string list is the header.
func (*Table) UnmarshalJSON ¶
UnmarshalJSON reads a list of json-encoded bytes into a table. Implements the json.Unmarshaller interface.
func (*Table) Validate ¶ added in v1.1.0
Validate returns an error if a table is in an invalid state.