loader

package
v0.0.0-...-a11b62f Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertDate

func ConvertDate(d string) string

ConvertDate 转换日期,把 05-16-20 格式的日期转换成 2020-05-16 格式,无法转换则返回原数据

func Slice

func Slice(row []string) (col []interface{})

Slice 把 []string 转换成 []interface{}

func UnQuote

func UnQuote(s []string) (d []string, err error)

UnQuote ConvertFunc 删除字符串的引号

Types

type ConvertFunc

type ConvertFunc func([]string) ([]string, error)

ConvertFunc 数据转换类型

func Exclude

func Exclude(columns ...int) ConvertFunc

Exclude ConvertFunc 剔除指定的列

func Include

func Include(columns ...int) ConvertFunc

Include ConvertFunc 仅包含指定的列

type Converter

type Converter struct {
	Reader // 源数据读取
	// contains filtered or unexported fields
}

Converter 数据转换类

func NewConverter

func NewConverter(r Reader, converters ...ConvertFunc) *Converter

NewConverter Converter 构造函数

func (*Converter) Read

func (c *Converter) Read() (rows []string, err error)

Read 读取方法

type Loader

type Loader struct {
	Ver string // 导入数据版本

	Clear bool // 是否清理数据库,默认为是
	Check bool // 是否需要检查文件导入
	// contains filtered or unexported fields
}

Loader 数据装入类

func NewLoader

func NewLoader(info os.FileInfo, name string, sql string, data Reader) *Loader

NewLoader Loader 构造函数

func (*Loader) Exec

func (l *Loader) Exec(tx *sqlite3.Tx) (err error)

Exec 执行导入操作

func (*Loader) Load

func (l *Loader) Load() error

Load 导入数据

func (*Loader) Test

func (l *Loader) Test()

Test 导入主函数

type Reader

type Reader interface {
	Read() ([]string, error)
}

Reader 数据读取接口

func NewXlsReader

func NewXlsReader(filename string, sheet int, skip int) Reader

NewXlsReader 读取 Excel 文件

type XlsFile

type XlsFile interface {
	Close() // 关闭文件
	Read(sheet int, skip int, converters ...ConvertFunc) Reader
}

XlsFile 接口

func NewXlsFile

func NewXlsFile(filename string) (file XlsFile, err error)

NewXlsFile 新建 xlsFile 根据文件扩展名自动判断

type XlsReader

type XlsReader struct {
	Sheet   *xls.WorkSheet
	CurLine int
}

XlsReader Excel 文件读取

func (*XlsReader) Read

func (s *XlsReader) Read() (res []string, err error)

Read 读取当前记录

Jump to

Keyboard shortcuts

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