Documentation
¶
Overview ¶
Package ingest reads tabular and record data — CSV, TSV, JSON and JSON Lines — into the feature values it assigns to model elements, one row per element.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Literal ¶
Literal writes a cell as the notation of the value it assigns a feature of class; enum qualifies the literal an enumeration cell names.
func SplitHeader ¶
SplitHeader takes a unit written in brackets off a column name: `mass [kg]` names column mass in kilograms.
Types ¶
type Cell ¶
type Cell struct {
Feature string
Text string
Kind Kind
// Type is the mapping's declared type for the value, "" to follow the feature's.
Type string
Unit string
// Where locates the value in the input, for a diagnostic.
Where string
}
Cell is one value a row assigns to a feature of its element.
type Field ¶
type Field struct {
Column string `json:"column,omitempty"`
Path string `json:"path,omitempty"`
// Prefix is written before an element name the record gives.
Prefix string `json:"prefix,omitempty"`
Unit string `json:"unit,omitempty"`
UnitColumn string `json:"unitColumn,omitempty"`
UnitPath string `json:"unitPath,omitempty"`
// Type is string, boolean, integer, real or number; "" follows the feature.
Type string `json:"type,omitempty"`
}
Field locates one value in a record: a column, or a JSON Pointer path.
type Format ¶
type Format string
Format is a representation the data is read from.
func FormatOfPath ¶
FormatOfPath is the format a data file's extension names.
func ParseFormat ¶
ParseFormat reads a format name; ndjson is JSON Lines.
type Map ¶
type Map struct {
// As is what the data is imported as; "values" sets feature values.
As string `json:"as,omitempty"`
// Format overrides the format the data file's extension names.
Format string `json:"format,omitempty"`
// Delimiter is the one character a delimited file's cells are split on.
Delimiter string `json:"delimiter,omitempty"`
// Records is a JSON Pointer to the array of records in a JSON document.
Records string `json:"records,omitempty"`
Element Field `json:"element,omitempty"`
Features map[string]Field `json:"features,omitempty"`
// Ignore names columns or top-level fields that set nothing.
Ignore []string `json:"ignore,omitempty"`
}
Map says how input columns and JSON fields map onto elements and features. Every field is optional: a column or field names the feature it sets, a bracketed suffix its unit, and the element column names the element.