csvtab

package module
v0.0.0-...-1a87079 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2015 License: MIT Imports: 8 Imported by: 0

README

csvtab

csv memory table. support orderby,distinct and query.

Documentation

Overview

csv 内存表 tabu 2014-08-05

Index

Constants

View Source
const (
	OrderAES = 1
	OrderDES = -1
)

Variables

This section is empty.

Functions

func LessFloatAES

func LessFloatAES(p1, p2 string) bool

func LessFloatDES

func LessFloatDES(p1, p2 string) bool

func LessStringAES

func LessStringAES(p1, p2 string) bool

func LessStringDES

func LessStringDES(p1, p2 string) bool

func OrderedBy

func OrderedBy(less []ColumnLess) *sorter

Types

type ColumnLess

type ColumnLess struct {
	Col  int
	Less LessFunc
}

type HashIndex

type HashIndex struct {
	Columns []string
	Index   map[string][]int
}

type KV

type KV struct {
	Name, Value string
}

by name

type LessFunc

type LessFunc func(p1, p2 string) bool

type Predicate

type Predicate func(row []string) bool

type Table

type Table struct {
	Columns  []string
	ColIndex map[string]int
	Rows     [][]string
	Indexs   []*HashIndex
}

func FromBytes

func FromBytes(bs []byte, comma rune) (*Table, error)

func FromFile

func FromFile(file string, comma rune) (*Table, error)

func NewTable

func NewTable() *Table

func ReadAll

func ReadAll(r *csv.Reader, header bool) (*Table, error)

func (*Table) AddColumns

func (t *Table) AddColumns(count int)

func (*Table) Append

func (t *Table) Append(row []string)

func (*Table) ColumnCount

func (t *Table) ColumnCount() int

func (*Table) CreateHashIndex

func (t *Table) CreateHashIndex(cols ...string) *HashIndex

hash index

func (*Table) Distinct

func (t *Table) Distinct(cols ...string) *Table

func (*Table) DistinctI

func (t *Table) DistinctI(cols []int) *Table

func (*Table) FindAll

func (t *Table) FindAll(start int, f Predicate) *Table

func (*Table) FindFirst

func (t *Table) FindFirst(start int, f Predicate) int

func (*Table) Get

func (t *Table) Get(i int, column string) string

func (*Table) GetCount

func (t *Table) GetCount() int

func (*Table) Map

func (t *Table) Map(names []string) ([]int, bool)

func (*Table) MapOf

func (t *Table) MapOf(column string) (index int, ok bool)

func (*Table) OrderBy

func (t *Table) OrderBy(columnLessFunc ...interface{}) *Table

column1,lessfunc1, column2, lessfunc2

func (*Table) Query

func (t *Table) Query(values ...KV) *Table

func (*Table) RowCount

func (t *Table) RowCount() int

func (*Table) Search

func (t *Table) Search(orderedColumnValue ...KV) int

func (*Table) SetColumns

func (t *Table) SetColumns(columns []string)

Jump to

Keyboard shortcuts

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