csv

package
v0.0.0-...-38d8e20 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Scanner)

Option is a func type received by NewScanner. Each one allows configuration of the scanner and/or its internal *csv.Reader.

func Comma

func Comma(comma rune) Option

func Comment

func Comment(comment rune) Option

func ContinueOnError

func ContinueOnError(continue_ bool) Option

ContinueOnError controls scanner behavior in error scenarios. If true is passed, continue scanning until io.EOF is reached. If false is passed (default), any error encountered during scanning will result in the next call to Scan returning false and the Scanner may be considered dead. See Scanner.Error() for the exact error (before the next call to Scanner.Scan()). See https://golang.org/pkg/encoding/csv/#pkg-variables and https://golang.org/pkg/encoding/csv/#ParseError for more information regarding possible error values.

func FieldsPerRecord

func FieldsPerRecord(fields int) Option

func LazyQuotes

func LazyQuotes(lazy bool) Option

func ReuseRecord

func ReuseRecord(reuse bool) Option

func SkipHeaderRecord

func SkipHeaderRecord() Option

func SkipRecords

func SkipRecords(count int) Option

func TrimLeadingSpace

func TrimLeadingSpace(trim bool) Option

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner wraps a csv.Reader via an API similar to that of bufio.Scanner.

func NewScanner

func NewScanner(reader io.Reader, options ...Option) *Scanner

NewScanner returns a scanner configured with the provided options.

func (*Scanner) Error

func (this *Scanner) Error() error

Error returns the last non-nil error produced by Scan (if there was one). It will not ever return io.EOF. This method may be called at any point during or after scanning but the underlying err will be reset by each call to Scan.

func (*Scanner) Record

func (this *Scanner) Record() []string

Record returns the most recent record generated by a call to Scan as a []string. See *csv.Reader.ReuseRecord for details on the strategy for reusing the underlying array: https://golang.org/pkg/encoding/csv/#Reader

func (*Scanner) Scan

func (this *Scanner) Scan() bool

Scan advances the Scanner to the next record, which will then be available through the Record method. It returns false when the scan stops, either by reaching the end of the input or an error. After Scan returns false, the Error method will return any error that occurred during scanning, except that if it was io.EOF, Error will return nil.

Jump to

Keyboard shortcuts

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