csvx

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanCsv added in v1.0.27

func ScanCsv(cr *csv.Reader, records any) error

ScanCsv read csv data to slice. Example:

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

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

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

ScanReader 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 CsvScanner added in v1.0.27

type CsvScanner struct {
	Head []string
	Line int
	// contains filtered or unexported fields
}

func NewScanner added in v1.0.27

func NewScanner(cr *csv.Reader) *CsvScanner

NewScanner returns a new csv scanner that reads from r.

func (*CsvScanner) ScanHead added in v1.0.27

func (cs *CsvScanner) ScanHead() error

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

func (*CsvScanner) ScanStruct added in v1.0.27

func (cs *CsvScanner) ScanStruct(rec any) error

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

func (*CsvScanner) ScanStructs added in v1.0.27

func (cs *CsvScanner) ScanStructs(recs any) error

Jump to

Keyboard shortcuts

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