csvstruct

package
v0.0.0-...-3241ae0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package csvstruct provides methods to decode a CSV file into a struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, slice any) (err error)

*

  • @description:
  • @param {[]byte} data
  • @param {any} v 数组地址
  • @return {*}

func DecodeWithAnsi

func DecodeWithAnsi(r io.Reader, v any) (err error)

*

  • @description: 解析ansi格式的csv
  • @param {io.Reader} r
  • @param {any} v 数组地址
  • @return {*}

Types

type DecodeOpts

type DecodeOpts struct {
	Comma            rune // field delimiter (set to ',' by default)
	Comment          rune // comment character for start of line
	LazyQuotes       bool // allow lazy quotes
	TrimLeadingSpace bool // trim leading space
}

DecodeOpts specifies options to modify decoding behavior.

type Decoder

type Decoder interface {
	// DecodeNext populates v with the values from the next row in the
	// Decoder's Reader.
	//
	// On the first call to DecodeNext, the first row in the reader will be
	// used as the header row to map CSV fields to struct fields, and the
	// second row will be read to populate v.
	DecodeNext(v interface{}) error

	// Opts specifies options to modify decoding behavior.
	//
	// It returns the Decoder, to support chaining.
	Opts(DecodeOpts) Decoder
}

Decoder reads and decodes CSV rows from an input stream.

func NewDecoder

func NewDecoder(r io.Reader) Decoder

NewDecoder returns a Decoder that reads from r.

func NewDocedeWithAnsi

func NewDocedeWithAnsi(r io.Reader) Decoder

*

  • @description: ansi 的编码识别
  • @param {io.Reader} r
  • @return {*}

type InvalidUnmarshalError

type InvalidUnmarshalError struct {
	Type reflect.Type
}

An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)

func (*InvalidUnmarshalError) Error

func (e *InvalidUnmarshalError) Error() string

Jump to

Keyboard shortcuts

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