detect

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 19 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidTabularData = errors.New("invalid tabular data")

ErrInvalidTabularData indicates non-tabular data in a context that expects tabular input

Functions

func CBORSchema

func CBORSchema(resource *dataset.Structure, data io.Reader) (schema map[string]interface{}, n int, err error)

CBORSchema determines the field names and types of an io.Reader of CBOR-formatted data, returning a json schema

func CSVSchema

func CSVSchema(resource *dataset.Structure, data io.Reader) (schema map[string]interface{}, n int, err error)

CSVSchema determines the field names and types of an io.Reader of CSV-formatted data, returning a json schema

func ExtensionDataFormat

func ExtensionDataFormat(path string) (format dataset.DataFormat, err error)

ExtensionDataFormat returns the corresponding DataFormat for a given file extension if one exists TODO - this should probably come from the dataset package

func FromFile

func FromFile(path string) (st *dataset.Structure, err error)

FromFile takes a filepath & tries to work out the corresponding dataset for the sake of speed, it only works with files that have a recognized extension

func FromReader

func FromReader(format dataset.DataFormat, data io.Reader) (st *dataset.Structure, n int, err error)

FromReader detects a dataset structure from a reader and data format, returning a detected dataset structure, the number of bytes read from the reader, and any error

func JSONSchema

func JSONSchema(resource *dataset.Structure, data io.Reader) (schema map[string]interface{}, n int, err error)

JSONSchema determines the field names and types of an io.Reader of JSON-formatted data, returning a json schema This is currently a suuuuuuuuper simple interpretation that spits out a generic schema that'll work. In the future we can do all sorts of stuff here to make better inferences about the shape of a dataset, but for now, this'll work, and we'll instead focus on making it easier for users to provide hand-built schemas

func Schema

func Schema(r *dataset.Structure, data io.Reader) (schema map[string]interface{}, n int, err error)

Schema determines the schema of a given reader for a given structure

func Structure added in v0.3.0

func Structure(ds *dataset.Dataset) error

Structure examines the contents of a dataset body, setting any missing elements of a structure component required to make the dataset readable. A minimum structure component has non-zero Format and Schema fields, and may need additional FormatConfig settings to parse properly. Structure will not mutate any component fields that are not a default value

func TabularSchemaFromTabularData added in v0.2.0

func TabularSchemaFromTabularData(source interface{}) (map[string]interface{}, error)

TabularSchemaFromTabularData infers a basic tabular JSON schema from go types it only works in the narrow case where the source data is known to be tabular but lacks a schema to describe it given the lack of metadata, these schema should be used primarily for machine purposes

func XLSXSchema

func XLSXSchema(r *dataset.Structure, data io.Reader) (schema map[string]interface{}, n int, err error)

XLSXSchema determines any schema information for an excel spreadsheet TODO (b5): currently unimplemented

Types

This section is empty.

Jump to

Keyboard shortcuts

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