gocsv: github.com/gocarina/gocsv Index | Files

package gocsv

import "github.com/gocarina/gocsv"

Index

Package Files

csv.go decode.go encode.go reflect.go safe_csv.go types.go unmarshaller.go

Variables

var FailIfDoubleHeaderNames = false

FailIfDoubleHeaderNames indicates whether it is considered an error when a header name is repeated in the csv header.

var FailIfUnmatchedStructTags = false

FailIfUnmatchedStructTags indicates whether it is considered an error when there is an unmatched struct tag.

var ShouldAlignDuplicateHeadersWithStructFieldOrder = false

ShouldAlignDuplicateHeadersWithStructFieldOrder indicates whether we should align duplicate CSV headers per their alignment in the struct definition.

var TagSeparator = ","

TagSeparator defines seperator string for multiple csv tags in struct fields

func CSVToMap Uses

func CSVToMap(in io.Reader) (map[string]string, error)

CSVToMap creates a simple map from a CSV of 2 columns.

func CSVToMaps Uses

func CSVToMaps(reader io.Reader) ([]map[string]string, error)

CSVToMaps takes a reader and returns an array of dictionaries, using the header row as the keys

func Marshal Uses

func Marshal(in interface{}, out io.Writer) (err error)

Marshal returns the CSV in writer from the interface.

func MarshalBytes Uses

func MarshalBytes(in interface{}) (out []byte, err error)

MarshalBytes returns the CSV bytes from the interface.

func MarshalCSV Uses

func MarshalCSV(in interface{}, out *SafeCSVWriter) (err error)

MarshalCSV returns the CSV in writer from the interface.

func MarshalCSVWithoutHeaders Uses

func MarshalCSVWithoutHeaders(in interface{}, out *SafeCSVWriter) (err error)

MarshalCSVWithoutHeaders returns the CSV in writer from the interface.

func MarshalChan Uses

func MarshalChan(c <-chan interface{}, out *SafeCSVWriter) error

MarshalChan returns the CSV read from the channel.

func MarshalFile Uses

func MarshalFile(in interface{}, file *os.File) (err error)

MarshalFile saves the interface as CSV in the file.

func MarshalString Uses

func MarshalString(in interface{}) (out string, err error)

MarshalString returns the CSV string from the interface.

func MarshalWithoutHeaders Uses

func MarshalWithoutHeaders(in interface{}, out io.Writer) (err error)

Marshal returns the CSV in writer from the interface.

func SetCSVReader Uses

func SetCSVReader(csvReader func(io.Reader) CSVReader)

SetCSVReader sets the CSV reader used to parse CSV.

func SetCSVWriter Uses

func SetCSVWriter(csvWriter func(io.Writer) *SafeCSVWriter)

SetCSVWriter sets the SafeCSVWriter used to format CSV.

func Unmarshal Uses

func Unmarshal(in io.Reader, out interface{}) error

Unmarshal parses the CSV from the reader in the interface.

func UnmarshalBytes Uses

func UnmarshalBytes(in []byte, out interface{}) error

UnmarshalBytes parses the CSV from the bytes in the interface.

func UnmarshalBytesToCallback Uses

func UnmarshalBytesToCallback(in []byte, f interface{}) error

UnmarshalBytesToCallback parses the CSV from the bytes and send each value to the given func f. The func must look like func(Struct).

func UnmarshalBytesToChan Uses

func UnmarshalBytesToChan(in []byte, c interface{}) error

UnmarshalBytesToChan parses the CSV from the bytes and send each value in the chan c. The channel must have a concrete type.

func UnmarshalCSV Uses

func UnmarshalCSV(in CSVReader, out interface{}) error

UnmarshalCSV parses the CSV from the reader in the interface.

func UnmarshalCSVWithoutHeaders Uses

func UnmarshalCSVWithoutHeaders(in CSVReader, out interface{}) error

UnmarshalCSVWithoutHeaders parses a headerless CSV with passed in CSV reader

func UnmarshalDecoder Uses

func UnmarshalDecoder(in Decoder, out interface{}) error

UnmarshalDecoder parses the CSV from the decoder in the interface

func UnmarshalDecoderToCallback Uses

func UnmarshalDecoderToCallback(in SimpleDecoder, f interface{}) error

UnmarshalDecoderToCallback parses the CSV from the decoder and send each value to the given func f. The func must look like func(Struct).

func UnmarshalDecoderToChan Uses

func UnmarshalDecoderToChan(in SimpleDecoder, c interface{}) error

UnmarshalDecoderToChan parses the CSV from the decoder and send each value in the chan c. The channel must have a concrete type.

func UnmarshalFile Uses

func UnmarshalFile(in *os.File, out interface{}) error

UnmarshalFile parses the CSV from the file in the interface.

func UnmarshalString Uses

func UnmarshalString(in string, out interface{}) error

UnmarshalString parses the CSV from the string in the interface.

func UnmarshalStringToCallback Uses

func UnmarshalStringToCallback(in string, c interface{}) (err error)

UnmarshalStringToCallback parses the CSV from the string and send each value to the given func f. The func must look like func(Struct).

func UnmarshalStringToChan Uses

func UnmarshalStringToChan(in string, c interface{}) error

UnmarshalStringToChan parses the CSV from the string and send each value in the chan c. The channel must have a concrete type.

func UnmarshalToCallback Uses

func UnmarshalToCallback(in io.Reader, f interface{}) error

UnmarshalToCallback parses the CSV from the reader and send each value to the given func f. The func must look like func(Struct).

func UnmarshalToChan Uses

func UnmarshalToChan(in io.Reader, c interface{}) error

UnmarshalToChan parses the CSV from the reader and send each value in the chan c. The channel must have a concrete type.

func UnmarshalWithoutHeaders Uses

func UnmarshalWithoutHeaders(in io.Reader, out interface{}) error

UnmarshalWithoutHeaders parses the CSV from the reader in the interface.

type CSVReader Uses

type CSVReader interface {
    Read() ([]string, error)
    ReadAll() ([][]string, error)
}

func DefaultCSVReader Uses

func DefaultCSVReader(in io.Reader) CSVReader

DefaultCSVReader is the default CSV reader used to parse CSV (cf. csv.NewReader)

func LazyCSVReader Uses

func LazyCSVReader(in io.Reader) CSVReader

LazyCSVReader returns a lazy CSV reader, with LazyQuotes and TrimLeadingSpace.

type Decoder Uses

type Decoder interface {
    // contains filtered or unexported methods
}

Decoder .

type NoMarshalFuncError Uses

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

NoMarshalFuncError is the custom error type to be raised in case there is no marshal function defined on type

func (NoMarshalFuncError) Error Uses

func (e NoMarshalFuncError) Error() string

type NoUnmarshalFuncError Uses

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

NoUnmarshalFuncError is the custom error type to be raised in case there is no unmarshal function defined on type

func (NoUnmarshalFuncError) Error Uses

func (e NoUnmarshalFuncError) Error() string

type SafeCSVWriter Uses

type SafeCSVWriter struct {
    *csv.Writer
    // contains filtered or unexported fields
}

func DefaultCSVWriter Uses

func DefaultCSVWriter(out io.Writer) *SafeCSVWriter

DefaultCSVWriter is the default SafeCSVWriter used to format CSV (cf. csv.NewWriter)

func NewSafeCSVWriter Uses

func NewSafeCSVWriter(original *csv.Writer) *SafeCSVWriter

func (*SafeCSVWriter) Flush Uses

func (w *SafeCSVWriter) Flush()

Override flush

func (*SafeCSVWriter) Write Uses

func (w *SafeCSVWriter) Write(row []string) error

Override write

type SimpleDecoder Uses

type SimpleDecoder interface {
    // contains filtered or unexported methods
}

SimpleDecoder .

type TypeMarshaller Uses

type TypeMarshaller interface {
    MarshalCSV() (string, error)
}

TypeMarshaller is implemented by any value that has a MarshalCSV method This converter is used to convert the value to it string representation

type TypeUnmarshaller Uses

type TypeUnmarshaller interface {
    UnmarshalCSV(string) error
}

TypeUnmarshaller is implemented by any value that has an UnmarshalCSV method This converter is used to convert a string to your value representation of that string

type Unmarshaller Uses

type Unmarshaller struct {
    MismatchedHeaders      []string
    MismatchedStructFields []string
    // contains filtered or unexported fields
}

Unmarshaller is a CSV to struct unmarshaller.

func NewUnmarshaller Uses

func NewUnmarshaller(reader *csv.Reader, out interface{}) (*Unmarshaller, error)

NewUnmarshaller creates an unmarshaller from a csv.Reader and a struct.

func (*Unmarshaller) Read Uses

func (um *Unmarshaller) Read() (interface{}, error)

Read returns an interface{} whose runtime type is the same as the struct that was used to create the Unmarshaller.

func (*Unmarshaller) ReadUnmatched Uses

func (um *Unmarshaller) ReadUnmatched() (interface{}, map[string]string, error)

The same as Read(), but returns a map of the columns that didn't match a field in the struct

Package gocsv imports 12 packages (graph) and is imported by 62 packages. Updated 2019-05-22. Refresh now. Tools for package owners.