parse

package
v0.0.0-...-2ac6bf7 Latest Latest
Warning

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

Go to latest
Published: May 13, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVOpts

type CSVOpts struct {
	// NumDecoders is the number of Go routines that will be used for processing
	// the CSV. Defaults to the number of CPU cores
	NumDecoders int

	// DateFormat is the format of Date strings used by the mapper to parse the dates
	DateFormat string

	// TrimSpaces determines whether spaces will be trimmed on fields
	TrimSpaces bool

	// FieldMap is a map of intergers representing the index of the column of the CSV row mapped
	// to the indicies of the field. On the struct(s if embedded).
	// If not specified, it will be generated using the first
	// row of the CSV mapped to struct tags of the mapper specified with "csv".
	FieldMap map[int][]int

	// SkipHeader determines whether a Header should be skipped
	SkipHeader bool

	// AbortOnFailedRow will cause the CSV parser to stop attempting to decode if it can't decode a row
	AbortOnFailedRow bool

	// Logger is the logger to be used. It defaults to the DefaultLogger set on ingest
	Logger ingest.Logger
}

CSVOpts are options used to configure a CSVProcessor

type CSVProcessor

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

A CSVProcessor is a processor that handles reading CSV files

func CSV

func CSV(mapper interface{}, opts ...CSVOpts) *CSVProcessor

CSV returns an *ingest.Processor that will read a File

func (*CSVProcessor) Name

func (c *CSVProcessor) Name() string

Name implements ingest.Runner for CSVProcessor

func (*CSVProcessor) ParseHeader

func (c *CSVProcessor) ParseHeader(headers []string)

ParseHeader builds a header map from a single row using the struct tags specified from the Map

func (*CSVProcessor) ParseRow

func (c *CSVProcessor) ParseRow(row []string) (interface{}, error)

ParseRow parses a single row and returns a new instance of the same type as the mapper.

func (*CSVProcessor) Run

func (c *CSVProcessor) Run(stage *ingest.Stage) error

Run implements ingest.Runner for CSVProcessor

func (*CSVProcessor) SkipAbortErr

func (c *CSVProcessor) SkipAbortErr() bool

SkipAbortErr saves us having to send nil errors back on abort

type HasCSVOpts

type HasCSVOpts interface {
	CSVOpts() CSVOpts
}

HasCSVOpts is an interface that a mapper can implement to set CSV options by default

type JSONOpts

type JSONOpts struct {
	AbortOnFailedObject bool
	Selector            string
	NumDecoders         int
	Logger              ingest.Logger
}

JSONOpts are options used to configre a JSONProcessor (and an FFJSONProcessor)

type JSONProcessor

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

A JSONProcessor is used to process JSON via encoding/json

func JSON

func JSON(mapper interface{}, opts ...JSONOpts) *JSONProcessor

JSON returns an *parse.JSONProcessor which will decode a JSON file to a specified struct

func (*JSONProcessor) Name

func (j *JSONProcessor) Name() string

Name implements ingest.Runner for JSONProcessor

func (*JSONProcessor) Run

func (j *JSONProcessor) Run(stage *ingest.Stage) error

Run implements ingest.Runner for JSONProcessor

func (*JSONProcessor) SetSelection

func (j *JSONProcessor) SetSelection(selection ...string)

SetSelection implements ingest.Selectable for JSONProcessor

func (*JSONProcessor) SkipAbortErr

func (j *JSONProcessor) SkipAbortErr() bool

SkipAbortErr saves us having to send nil errors back on abort

Jump to

Keyboard shortcuts

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