csv

package module
v0.0.0-...-eb5b569 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 9 Imported by: 0

README

csv-go

Why does this exist?

I am tired of rewriting this over and over to cover edge cases where other language standard csv implementations have assertions on the format and formatting I can cannot guarantee are valid. I've written variations that cover far less concerns over the years and figured I'll make a superset of one that does everything I need. I'll likely refactor this at the end again to optimize for more speed or concurrency.

It's not 1.0 so don't use it in a production context until I lock it and get 100% test coverage.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedHeaderRowContents   = errors.New("header row values do not match expectations")
	ErrBadRecordSeparator            = errors.New("record separator can only be one rune long or \"\r\n\"")
	ErrIncompleteQuotedField         = fmt.Errorf("incomplete quoted field: %w", UnexpectedEOFError{})
	ErrUnexpectedEndOfEscapeSequence = fmt.Errorf("expecting an escaped character in a quoted field: %w", UnexpectedEOFError{})
	ErrBadEscapeSequence             = errors.New("found escape character not followed by a quote or another escape character")
	ErrBadEscapeAtStartOfRecord      = errors.New("escape character found outside the context of a quoted field when expecting the start of a record")
	ErrBadEscapeAtStartOfField       = errors.New("escape character found outside the context of a quoted field when expecting the start of a field")
	ErrBadEscapeInUnquotedField      = errors.New("escape character found outside the context of a quoted field when processing an unquoted field")
	ErrInvalidQuotedFieldEnding      = errors.New("unexpected character found after end of quoted field") // expecting field separator, record separator, quote char, or end of file if field count matches expectations
	ErrNoHeaderRow                   = fmt.Errorf("no header row: %w", UnexpectedEOFError{})
	ErrNoRows                        = fmt.Errorf("no rows: %w", UnexpectedEOFError{})
	// config errors
	ErrNilReader = errors.New("nil reader")
)

Functions

func ReaderOpts

func ReaderOpts() readerOpts

Types

type ConfigurationError

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

func (ConfigurationError) Error

func (e ConfigurationError) Error() string

func (ConfigurationError) Unwrap

func (e ConfigurationError) Unwrap() error

type ErrFieldCountMismatch

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

func (ErrFieldCountMismatch) Error

func (e ErrFieldCountMismatch) Error() string

type ErrTooManyFields

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

func (ErrTooManyFields) Error

func (e ErrTooManyFields) Error() string

type IOError

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

func (IOError) Error

func (e IOError) Error() string

func (IOError) Unwrap

func (e IOError) Unwrap() error

type ParsingError

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

func (ParsingError) Error

func (e ParsingError) Error() string

func (ParsingError) Unwrap

func (e ParsingError) Unwrap() error

type Reader

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

func NewReader

func NewReader(options ...ReaderOption) (*Reader, error)

func (*Reader) Err

func (r *Reader) Err() error

func (*Reader) Row

func (r *Reader) Row() []string

Row returns a slice of strings that represents a row of a dataset.

Row only returns valid results after a call to Scan() return true. For efficiency reasons this method should not be called more than once between calls to Scan().

If the reader is configured with BorrowRow(true) then the resulting slice and field strings are only valid to use up until the next call to Scan and should not be saved to persistent memory.

func (*Reader) Scan

func (r *Reader) Scan() bool

type ReaderOption

type ReaderOption func(*rCfg)

type UnexpectedEOFError

type UnexpectedEOFError struct{}

func (UnexpectedEOFError) Error

func (e UnexpectedEOFError) Error() string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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