csv

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrInvalidCSV added in v1.0.4

func IsErrInvalidCSV(err error) bool

IsErrInvalidCSV checks if the `err` is of ErrInvalidCSV type.

func NewCSVFileFormat added in v1.0.4

func NewCSVFileFormat(schemaName string) fileformat.FileFormat

NewCSVFileFormat creates a FileFormat for 'csv2'.

func NewReader added in v1.0.4

func NewReader(
	inputName string, r io.Reader, decl *FileDecl, targetXPathExpr *xpath.Expr) *reader

NewReader creates an FormatReader for csv file format.

Types

type ColumnDecl

type ColumnDecl struct {
	Name        string  `json:"name,omitempty"`
	Index       *int    `json:"index,omitempty"`        // 1-based. optional.
	LineIndex   *int    `json:"line_index,omitempty"`   // 1-based. optional
	LinePattern *string `json:"line_pattern,omitempty"` // optional
	// contains filtered or unexported fields
}

ColumnDecl describes a column of an csv record column.

type ErrInvalidCSV added in v1.0.4

type ErrInvalidCSV string

ErrInvalidCSV indicates the csv content is corrupted or IO failure. This is a fatal, non-continuable error.

func (ErrInvalidCSV) Error added in v1.0.4

func (e ErrInvalidCSV) Error() string

Error implements error interface.

type FileDecl

type FileDecl struct {
	Delimiter           string        `json:"delimiter,omitempty"`
	ReplaceDoubleQuotes bool          `json:"replace_double_quotes,omitempty"`
	Records             []*RecordDecl `json:"records,omitempty"`
}

FileDecl describes csv/delimited schema `file_declaration` setting.

type RecordDecl

type RecordDecl struct {
	Name     string        `json:"name,omitempty"`
	Rows     *int          `json:"rows,omitempty"`
	Header   *string       `json:"header,omitempty"`
	Footer   *string       `json:"footer,omitempty"`
	Type     *string       `json:"type,omitempty"`
	IsTarget bool          `json:"is_target,omitempty"`
	Min      *int          `json:"min,omitempty"`
	Max      *int          `json:"max,omitempty"`
	Columns  []*ColumnDecl `json:"columns,omitempty"`
	Children []*RecordDecl `json:"child_records,omitempty"`
	// contains filtered or unexported fields
}

RecordDecl describes an record of a csv/delimited input. If Rows/Header/Footer are all nil, then it defaults to Rows = 1. If Rows specified, then Header/Footer must be nil. (JSON schema validation will ensure this.) If Header is specified, Rows must be nil. (JSON schema validation will ensure this.) Footer is optional; If not specified, Header will be used for a single-line record matching.

func (*RecordDecl) ChildDecls

func (r *RecordDecl) ChildDecls() []flatfile.RecDecl

func (*RecordDecl) DeclName

func (r *RecordDecl) DeclName() string

func (*RecordDecl) Group

func (r *RecordDecl) Group() bool

func (*RecordDecl) MaxOccurs

func (r *RecordDecl) MaxOccurs() int

MaxOccurs defaults to unbounded. CSV/delimited input most common scenario is min=0/max=unbounded.

func (*RecordDecl) MinOccurs

func (r *RecordDecl) MinOccurs() int

MinOccurs defaults to 0. CSV/delimited input most common scenario is min=0/max=unbounded.

func (*RecordDecl) Target

func (r *RecordDecl) Target() bool

Jump to

Keyboard shortcuts

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