csvstruct: github.com/ImJasonH/csvstruct Index | Files

package csvstruct

import "github.com/ImJasonH/csvstruct"

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


Package Files

decode.go encode.go

type DecodeOpts Uses

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 Uses

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 Uses

func NewDecoder(r io.Reader) Decoder

NewDecoder returns a Decoder that reads from r.

type EncodeOpts Uses

type EncodeOpts struct {
    SkipHeader bool // True to skip writing the header row
    Comma      rune // Field delimiter (set to ',' by default)
    UseCRLF    bool // True to use \r\n as the line terminator

EncodeOpts specifies options to modify encoding behavior.

type Encoder Uses

type Encoder interface {
    // EncodeNext encodes v into a CSV row and writes it to the Encoder's
    // Writer.
    // On the first call to EncodeNext, v's fields will be used to write the
    // header row, then v's values will be written as the second row.
    EncodeNext(v interface{}) error

    // Opts specifies options to modify encoding behavior.
    // It returns the Encoder, to support chaining.
    Opts(EncodeOpts) Encoder

Encoder encodes and writes CSV rows to an output stream.

func NewEncoder Uses

func NewEncoder(w io.Writer) Encoder

NewEncoder returns an encoder that writes to w.

Package csvstruct imports 9 packages (graph) and is imported by 1 packages. Updated 2016-07-16. Refresh now. Tools for package owners.