csvw

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(ctx context.Context, metadata *dataset.Metadata, header, downloadURL, aboutURL, apiDomain string) ([]byte, error)

Generate the CSVW structured metadata file to describe a CSV

Types

type CSVW

type CSVW struct {
	Context     string    `json:"@context"`
	URL         string    `json:"url"`
	Title       string    `json:"dct:title"`
	Description string    `json:"dct:description,omitempty"`
	Issued      string    `json:"dct:issued,omitempty"`
	Publisher   Publisher `json:"dct:publisher"`
	Contact     []Contact `json:"dcat:contactPoint"`
	TableSchema Columns   `json:"tableSchema"`
	Theme       string    `json:"dcat:theme,omitempty"`
	License     string    `json:"dct:license,omitempty"`
	Frequency   string    `json:"dct:accrualPeriodicity,omitempty"`
	Notes       []Note    `json:"notes,omitempty"`
}

CSVW provides a structure for describing a CSV through a JSON metadata file. The JSON tags feature web vocabularies like Dublin Core, DCAT and Stat-DCAT to help further contextualize and define the metadata being provided. The URL field in the CSVW must reference a CSV file, and all other data should describe that CSVs contents.

func New

func New(m *dataset.Metadata, csvURL string) *CSVW

New CSVW returned with top level fields populated based on provided metadata

func (*CSVW) AddNotes

func (csvw *CSVW) AddNotes(metadata *dataset.Metadata, url string)

AddNotes to CSVW from alerts or usage notes in provided metadata

type Column

type Column map[string]interface{}

Column provides the ability to define the JSON tags required specific to each column within the CSVW

type Columns

type Columns struct {
	C     []Column `json:"columns"`
	About string   `json:"aboutUrl"`
}

Columns provides the nested structure expected within the tableSchema of a CSVW

type Contact

type Contact struct {
	Name      string `json:"vcard:fn"`
	Telephone string `json:"vcard:tel"`
	Email     string `json:"vcard:email"`
}

Contact represents a response model within a dataset

type Note

type Note struct {
	Type       string `json:"type"` // is this an enum?
	Target     string `json:"target,omitempty"`
	Body       string `json:"body"`
	Motivation string `json:"motivation,omitempty"` // how is this different from type? do we need this? is this an enum?
}

Note can include alerts, corrections or usage notes which exist in the dataset metadata and help describe the contents of the CSV

type Publisher

type Publisher struct {
	Name string `json:"name,omitempty"`
	Type string `json:"@type,omitempty"`
	ID   string `json:"@id"` // a URL where more info is available
}

Publisher defines the entity primarily responsible for the dataset https://www.w3.org/TR/vocab-dcat/#class-catalog

Jump to

Keyboard shortcuts

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