csv

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvSliceToRecordFunc

type CsvSliceToRecordFunc func(v []string, m Meta) Record

type Meta

type Meta struct {
	Id int
}

type Record

type Record interface{}

type RecordToCsvFunc

type RecordToCsvFunc func(r Record, m Meta) []string

type Table

type Table struct {
	//文件路径
	FileName string
	//数据开始行,值从0开始 默认1  第一行一般为列名
	StartRow int

	Comma, Comment rune
	UseCRLF        bool
	// contains filtered or unexported fields
}

csv操作封装 为了便于操作 数据采用map存储

func NewTable

func NewTable(filename string, f1 RecordToCsvFunc, f2 CsvSliceToRecordFunc) *Table

func (*Table) GetRecords

func (t *Table) GetRecords(cond ...func(r Record, m Meta) bool) []Record

按条件查找记录

func (*Table) GetRecordsAndMeta

func (t *Table) GetRecordsAndMeta(cond ...func(r Record, m Meta) bool) (rs []Record, ms []Meta)

按条件查找记录

func (*Table) Insert

func (t *Table) Insert(record Record) error

添加记录

func (*Table) Read

func (t *Table) Read() error

读取所有数据

func (*Table) RemoveRecordById

func (t *Table) RemoveRecordById(id int) error

按ID更新记录

func (*Table) SetRecordByCond

func (t *Table) SetRecordByCond(new Record, cond ...func(r Record, m Meta) bool) error

按条件更新记录

func (*Table) SetRecordById

func (t *Table) SetRecordById(new Record, id int) error

按ID更新记录

func (*Table) WriteAll

func (t *Table) WriteAll() error

重置所有数据

Jump to

Keyboard shortcuts

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