csv

package
v1.0.0-beta6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const CSV = ls.LS + "csv/"

Variables

View Source
var (
	ColumnIndexTerm = ls.NewTerm(CSV+"columnIndex", false, false, ls.OverrideComposition, nil)
	ColumnNameTerm  = ls.NewTerm(CSV+"columnName", false, false, ls.OverrideComposition, nil)
)

Functions

func Import

func Import(attributeID AttributeSpec, terms []TermSpec, startRow, nRows int, input [][]string) (*ls.Layer, error)

Import a CSV schema. The CSV file is organized as columns, one column for base attribute names, and other columns for overlays. CSV does not support nested attributes. Returns an array of Layer objects

Types

type AttributeSpec

type AttributeSpec struct {
	// The 0-based column containing term data
	TermCol int `json:"column"`
	// If nonempty, this template is used to build the term contents
	// with {{.term}}, {{.data}}, and {{.row}} in template context. {{.term}} gives
	// the Term, and {{.data}} gives the value of the term in the
	// current cell.
	TermTemplate string `json:"template"`

	// If evaluates to a nonempty string, the attribute is an array whose elements are of this type
	ArrayTypeTemplate string `json:"arrayTypeTemplate"`
	ArrayIDTemplate   string `json:"arrayIdTemplate"`
}

type ErrColIndexOutOfBounds

type ErrColIndexOutOfBounds struct {
	For   string
	Index int
}

func (ErrColIndexOutOfBounds) Error

func (e ErrColIndexOutOfBounds) Error() string

type ErrInvalidID

type ErrInvalidID struct {
	Row int
}

func (ErrInvalidID) Error

func (e ErrInvalidID) Error() string

type ImportSpec

type ImportSpec struct {
	AttributeID TermSpec

	Terms []TermSpec
}

type Ingester

type Ingester struct {
	Schema      *ls.Layer
	ColumnNames []string
	Target      *digraph.Graph

	UseInstanceOfEdges bool
}

func (Ingester) Ingest

func (ingester Ingester) Ingest(data []string, ID string) (ls.Node, error)

type TermSpec

type TermSpec struct {
	// The term
	Term string `json:"term"`
	// The 0-based column containing term data
	TermCol int `json:"column"`
	// If nonempty, this template is used to build the term contents
	// with {{.term}}, {{.data}}, and {{.row}} in template context. {{.term}} gives
	// the Term, and {{.data}} gives the value of the term in the
	// current cell.
	TermTemplate string `json:"template"`
	// Is property an array
	Array bool `json:"array"`
	// Array separator character
	ArraySeparator string `json:"separator"`
}

Jump to

Keyboard shortcuts

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