Documentation
¶
Overview ¶
Package dataimport lowers the rows of a CSV, TSV, JSON or JSON Lines file to the edits that set the feature values they assign, one row per element, as `sysml -import` and the service's ImportData both apply them.
Index ¶
- func Lower(idx *symbols.Index, resolver *resolve.Resolver, sem *semantics.Model, ...) ([]Assignment, Summary, error)
- func Read(name string, data []byte, opts Options) ([]ingest.Row, error)
- func ReadFile(path, name, mapPath string, format string) ([]ingest.Row, error)
- type Assignment
- type Options
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Lower ¶
func Lower(idx *symbols.Index, resolver *resolve.Resolver, sem *semantics.Model, own func(doc string) bool, rows []ingest.Row) ([]Assignment, Summary, error)
Lower lowers rows to edits: a feature the element declares has its value set, one it inherits is redefined in the element's body with the value. own says whether a document is the model's own, so an element of another is refused.
Types ¶
type Assignment ¶
type Assignment struct {
// Op is the edit, on the document Doc at the declaration at offset At.
Op sedit.Operation
Doc string
At int
// Where is the row or cell of the data the assignment came from.
Where string
// Element is the qualified name of the element whose feature is set, Feature
// the feature's name and Value the literal it is set to; Redefines is the
// qualified name of the inherited feature redefined to set it, "" when the
// element declares the feature itself. A redefinition made only to reach a
// nested inherited feature sets no Value.
Element string
Feature string
Value string
Redefines string
}
Assignment is one edit an import makes: the value it sets on a feature, or the redefinition it declares to set one, and where in the data it came from.
func (Assignment) Description ¶
func (a Assignment) Description() string
Description spells the assignment as `sysml -import` reports it.
type Options ¶
type Options struct {
// Mapping is the JSON mapping, nil for the file's own header.
Mapping []byte
// Format is csv, tsv, json or jsonl; "" reads the mapping's, else the extension's.
Format string
}
Options are how a data file is read: a mapping onto elements and features, and a format overriding the one its extension names.