csvx

package
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanFile

func ScanFile(name string, records any) error

ScanFile read csv file data to slice. Example:

var s1 []*struct{I int, B bool}
ScanFile("s1.csv", &s1)

var S2 []struct{I int, B bool}
ScanFile("s2.csv", &s2)

func ScanReader

func ScanReader(r io.Reader, records any) error

ScanFile read csv data to slice. Example:

var s1 []*struct{I int, B bool}
ScanReader(r1, &s1)

var S2 []struct{I int, B bool}
ScanReader(r2, &s2)

Types

type CsvReader

type CsvReader struct {
	*csv.Reader

	Header []string
}

func NewReader

func NewReader(r io.Reader) *CsvReader

NewReader returns a new Reader that reads from r.

func (*CsvReader) ReadHeader

func (cr *CsvReader) ReadHeader() error

ReadHeader reads one record from csv and treat it as header.

func (*CsvReader) ScanStruct

func (cr *CsvReader) ScanStruct(rec any) (err error)

ScanStruct reads one record from csv and scan it to the parameter `rec`. The parameter `rec` should be a pointer to struct.

func (*CsvReader) ScanStructs

func (cr *CsvReader) ScanStructs(recs any) (err error)

Jump to

Keyboard shortcuts

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