csv

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Marshaller

type Marshaller interface {
	MarshalCSV() ([]string, error)
}

Marshaller is the interface implemented by types that can marshal themselves into valid CSV record.

type Store

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

Store allows to store data in csv format

func NewStore

func NewStore(path string) *Store

NewStore creates a Store which data is kept in file path

func (*Store) Close

func (s *Store) Close() error

func (*Store) Open

func (s *Store) Open(createIfNotExist bool) (err error)

Open the store file

func (*Store) ReadAll

func (s *Store) ReadAll() ([][]string, error)

ReadAll reads all CSV records from disk

func (*Store) ReadAllStructs

func (s *Store) ReadAllStructs(v interface{}) error

ReadAllStructs reads all CSV records from disk and set it into v It assumes v to be a pointer to a slice of object implementing the Unmarshaller interface

func (*Store) Reader

func (s *Store) Reader() *csv.Reader

Reader returns CSV reader You MUST call Open() before calling Reader

func (*Store) WriteAll

func (s *Store) WriteAll(records [][]string) error

WriteAll writes all CSV records to disk

func (*Store) WriteAllStructs

func (s *Store) WriteAllStructs(values []interface{}) error

WriteAllStructs writes all values to disk It expects all values to implement Marshaller interface

func (*Store) Writer

func (s *Store) Writer() *csv.Writer

Writer returns CSV writer You MUST call Open(true) before calling Writer

type Unmarshaller

type Unmarshaller interface {
	UnmarshalCSV([]string) error
}

Unmarshaler is the interface implemented by types that can unmarshal a CSV record description of themselves.

Jump to

Keyboard shortcuts

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