dl

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package dl provides a simple data loader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBlank added in v0.0.2

func IsBlank(xs []string) bool

IsBlank checks if xs is blank.

func IsNotBlank added in v0.0.2

func IsNotBlank(xs []string) bool

IsNotBlank checks if xs is not blank

func OpenFile added in v0.2.1

func OpenFile(name string) (*xlsx.Book, error)

OpenFile opens the workbook from file.

Types

type Loader

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

Loader represents a data loader.

func New

func New() *Loader

New creates a new default data loader.

func (*Loader) Comma

func (a *Loader) Comma(c rune) *Loader

Comma sets the comma for csv.

func (*Loader) Comment

func (a *Loader) Comment(c rune) *Loader

Comment sets the comment for csv.

func (*Loader) Drop

func (a *Loader) Drop(n int) *Loader

Drop drops the last n lines.

func (*Loader) DropBlank

func (a *Loader) DropBlank(o bool) *Loader

DropBlank drops blank lines.

func (*Loader) Head

func (a *Loader) Head(n int) *Loader

Head set the head lines.

func (*Loader) IgnoreBlank added in v0.0.2

func (a *Loader) IgnoreBlank(o bool) *Loader

IgnoreBlank ignores blank lines.

func (*Loader) LazyQuotes

func (a *Loader) LazyQuotes(o bool) *Loader

LazyQuotes sets the lazy quotes option for csv.

func (*Loader) LoadBook

func (a *Loader) LoadBook(book *xlsx.Book, sheet string) *st.Stream[[]Value]

LoadBook loads data from book.

func (*Loader) LoadCSV

func (a *Loader) LoadCSV(cr *csv.Reader) *st.Stream[[]Value]

LoadCSV loads data from csv reader.

func (*Loader) LoadFile

func (a *Loader) LoadFile(filename string, sheet string) *st.Stream[[]Value]

LoadFile loads data from file.

func (*Loader) LoadReader

func (a *Loader) LoadReader(typ Type, r io.Reader, sheet string) *st.Stream[[]Value]

LoadReader loads data from reader.

func (*Loader) LoadSheet

func (a *Loader) LoadSheet(sheet *xlsx.Sheet) *st.Stream[[]Value]

LoadSheet loads data from sheet.

func (*Loader) LoadStream

func (a *Loader) LoadStream(s *st.Stream[[]string]) *st.Stream[[]Value]

LoadStream loads data from stream.

func (*Loader) LoadZIP

func (a *Loader) LoadZIP(zr *zip.Reader, sheet string) *st.Stream[[]Value]

LoadZIP loads data from zip reader.

func (*Loader) Pick

func (a *Loader) Pick(fields ...string) *Loader

Pick picks the fields.

func (*Loader) Separator

func (a *Loader) Separator(s string) *Loader

Separator sets the separator for fields.

func (*Loader) Skip

func (a *Loader) Skip(n int) *Loader

Skip skips the first n lines.

func (*Loader) SkipBlank

func (a *Loader) SkipBlank(o bool) *Loader

SkipBlank skips blank lines.

func (*Loader) Transformer

func (a *Loader) Transformer(t transform.Transformer) *Loader

Transformer sets the transformer for csv.

func (*Loader) TrimSpace

func (a *Loader) TrimSpace(o bool) *Loader

TrimSpace trims the space.

func (*Loader) WithIndex

func (a *Loader) WithIndex(o bool) *Loader

WithIndex makes fields with index.

type Type

type Type string

Type represents a data type.

const (
	Unknown Type = ""
	CSV     Type = ".csv"
	XLSX    Type = ".xlsx"
)

Types.

type Value

type Value string

Value represents a common value.

func (Value) Bool

func (a Value) Bool() bool

Bool gets the value as bool.

func (Value) Float

func (a Value) Float() float64

Float gets the value as float64.

func (Value) Int

func (a Value) Int() int

Int gets the value as int.

func (Value) String

func (a Value) String() string

String gets the value as string.

Jump to

Keyboard shortcuts

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