pitaya

package module
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 10 Imported by: 0

README

go get github.com/f2xb/pitaya

Documentation

Index

Constants

View Source
const (
	Xlsx = ".xlsx"
	Xls  = ".xls"
	Csv  = ".csv"
	Txt  = ".txt"
	Dat  = ".dat"
)

Variables

View Source
var (
	ErrNotSupportFileType = errors.New("file type not supported")
)

Functions

This section is empty.

Types

type Col added in v0.0.10

type Col struct {
	// contains filtered or unexported fields
}

func (*Col) Contains added in v0.0.10

func (c *Col) Contains(strs ...string) (list []*DataFrame)

func (*Col) First added in v0.0.10

func (c *Col) First(str string) *DataFrame

func (*Col) Foreach added in v0.0.10

func (c *Col) Foreach(fn dfFunc)

func (*Col) Get added in v0.0.10

func (c *Col) Get(strs ...string) (list []*DataFrame)

func (*Col) Last added in v0.0.10

func (c *Col) Last(str string) *DataFrame

func (*Col) MaxRow added in v0.0.10

func (c *Col) MaxRow() int

func (*Col) String added in v0.0.10

func (c *Col) String() string

type DataFrame

type DataFrame struct {
	Col, Row int
	Value    string
	RawValue string
	Sheet    string
}

func (*DataFrame) String added in v0.0.10

func (df *DataFrame) String() string

String format print

type DataTable

type DataTable struct {
	Ext string
	// contains filtered or unexported fields
}

func Read

func Read(filePath string, opts ...Options) (*DataTable, error)

func ReadCsv

func ReadCsv(filePath string, opts ...Options) (*DataTable, error)

func ReadDat added in v0.0.5

func ReadDat(filePath string, opts ...Options) (dt *DataTable, err error)

func ReadTxt

func ReadTxt(filePath string, opts ...Options) (dt *DataTable, err error)

func ReadXls

func ReadXls(filePath string, opts ...Options) (*DataTable, error)

func ReadXlsx

func ReadXlsx(filePath string, opts ...Options) (*DataTable, error)

func (*DataTable) Contains

func (dt *DataTable) Contains(str string, sheets ...string) (list []*DataFrame)

Contains Get contains str df default sheet[0] Example: ----------------- A1 B1 C1 A2 aa bb A3 aa bb ----------------- Contains("A") // return: [A1, A2, A3] Contains("A", "Sheet1") // return: [A1, A2, A3]

func (*DataTable) First

func (dt *DataTable) First(str string, sheets ...string) *DataFrame

First get df, str eq df.value default sheet[0] Example: ----------------- A1 B1 C1 A2 aa bb A3 aa bb ----------------- First("aa") // return: {Sheet:Sheet1,Row:2,Col:2,Value:aa,RawValue:aa} First("aa", "Sheet1")

func (*DataTable) Foreach added in v0.0.10

func (dt *DataTable) Foreach(fn dfFunc, sheets ...string)

Foreach for range all df default sheet[0]

func (*DataTable) ForeachRow added in v0.0.10

func (dt *DataTable) ForeachRow(fn rowFunc, sheets ...string)

ForeachRow for range all row default sheet[0]

func (*DataTable) Get

func (dt *DataTable) Get(str string, sheets ...string) (list []*DataFrame)

Get Get df.Value eq str default sheet[0] Example: ----------------- A1 B1 C1 A2 aa bb A3 aa bb ----------------- Get("A1") // return: [A1] Get("A1", "Sheet1") // return: [A1]

func (*DataTable) GetCell

func (dt *DataTable) GetCell(row, col int, sheets ...string) *DataFrame

GetCell get cell by row, col default sheet[0] Example: ----------------- A1 B1 C1 A2 aaa bb A3 aaa bb A4 aaa bb ----------------- GetCell(1, 1) // return: A1 GetCell(1, 3, "Sheet1") // return: B1

func (*DataTable) GetCellByVal added in v0.0.10

func (dt *DataTable) GetCellByVal(row, col string, sheets ...string) *DataFrame

GetCellByVal get cell by row str, col str default sheet[0] Example: ----------------- A1 B1 C1 A2 aaa bb A3 aaa bb A4 aaa bb ----------------- GetCellByVal("A4", "C1") // return: bb GetCellByVal("A4", "B1", "Sheet1") // return: aaa

func (*DataTable) GetCol added in v0.0.7

func (dt *DataTable) GetCol(col int, sheets ...string) (c *Col)

GetCol get col default sheet[0] Example: ----------------- A1 B1 C1 A2 aa bb A3 aa bb ----------------- GetCol(1) // return: A1, A2, A3 GetCol(2, "Sheet1") // return: B1, aa, aa

func (*DataTable) GetRow added in v0.0.7

func (dt *DataTable) GetRow(row int, sheets ...string) (r *Row)

GetRow get row default sheet[0] Example: ----------------- A1 B1 C1 A2 aa bb A3 aa bb ----------------- GetRow(1) // return: A1, B1, C1 GetRow(2, "Sheet1") // return: A2, aa, bb

func (*DataTable) GetSheetByIndex added in v0.0.7

func (dt *DataTable) GetSheetByIndex(idx int) string

GetSheetByIndex Get sheet name by index Example: GetSheetByIndex(1) // return: Sheet1

func (*DataTable) GetSheets

func (dt *DataTable) GetSheets() []string

GetSheets Get all sheet name Example: GetSheets() // return: [Sheet1]

func (*DataTable) Last

func (dt *DataTable) Last(str string, sheets ...string) *DataFrame

Last get df, str eq df.value default sheet[0] Example: ----------------- A1 B1 C1 A2 aa bb A3 aa bb ----------------- Last("aa") // return: {Sheet:Sheet1,Row:3,Col:2,Value:aa,RawValue:aa} Last("aa", "Sheet1")

func (*DataTable) MaxRow added in v0.0.7

func (dt *DataTable) MaxRow(sheets ...string) (total int)

MaxRow Get the maximum number of rows default sheet[0] Example: MaxRow() // return: 4 MaxRow("Sheet2") // return: 1

func (*DataTable) Rows added in v0.0.10

func (dt *DataTable) Rows(sheets ...string) (list []*Row)

Rows Get rows default sheet[0] Example: ----------------- A1 B1 C1 A2 B2 C2 ----------------- Rows() Rows("Sheet1")

type Options

type Options struct {
	Password  string
	TrimSpace bool
	AllSheet  bool
	ColSep    string // default \t
	RowSep    string // default \n
	XlsxLib   string // default 'excelize' or 'xlsx'
}

type Row added in v0.0.10

type Row struct {
	// contains filtered or unexported fields
}

func (*Row) Contains added in v0.0.10

func (r *Row) Contains(strs ...string) (list []*DataFrame)

func (*Row) First added in v0.0.10

func (r *Row) First(str string) *DataFrame

func (*Row) Foreach added in v0.0.10

func (r *Row) Foreach(fn dfFunc)

func (*Row) Get added in v0.0.10

func (r *Row) Get(strs ...string) (list []*DataFrame)

func (*Row) Last added in v0.0.10

func (r *Row) Last(str string) *DataFrame

func (*Row) MaxCol added in v0.0.10

func (r *Row) MaxCol() int

func (*Row) String added in v0.0.10

func (r *Row) String() string

Jump to

Keyboard shortcuts

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