gocsv

package module
v0.0.0-...-3507cd6 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2014 License: MIT Imports: 4 Imported by: 0

README

gocsv GoDoc

Helper Library for Reading CSV Files with a Header Line

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	*csv.Reader
	TrimTrailingSpace bool
	FieldIndex        map[string]int
	Field             []string
}

A Reader may be constructed using either the New function, or directly by setting the Reader member to an existing csv.Reader and calling ReadHeader().

func NewReader

func NewReader(r io.Reader) (c *Reader, err error)

NewReader constructs a Reader object, reading the first line from the supplied io.Reader and interpreting it as a header line.

func NewTrimmingReader

func NewTrimmingReader(r io.Reader, trimLeading bool, trimTrailing bool) (c *Reader, err error)

func (*Reader) Read

func (c *Reader) Read() (Record, error)

func (*Reader) ReadAll

func (c *Reader) ReadAll() ([]Record, error)

func (*Reader) ReadHeader

func (c *Reader) ReadHeader() error

type Record

type Record map[string]string

type Writer

type Writer struct {
	*csv.Writer
	AllowUnknown bool
	FieldIndex   map[string]int
	Field        []string
}

func NewWriter

func NewWriter(w io.Writer, fields []string) *Writer

func (*Writer) Write

func (w *Writer) Write(values Record) error

func (*Writer) WriteHeader

func (w *Writer) WriteHeader() error

Jump to

Keyboard shortcuts

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