csvw

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 10 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, downloadURL, aboutURL, apiDomain, externalPrefixURL, filterOutputID, downloadServiceURL string, isCustom bool) ([]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,omitempty"`
	Contact     []Contact `json:"dcat:contactPoint,omitempty"`
	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"`
	// New fields
	Downloads     map[string]Download `json:"dcat:distribution,omitempty"`
	Keywords      []string            `json:"dcat:keyword,omitempty"`
	UnitOfMeasure string              `json:"dcat:conformsTo,omitempty"`
	Version       int                 `json:"dcat:version,omitempty"`
	IsBasedOn     string              `json:"prov:wasGeneratedBy,omitempty"`
	DatasetLinks  *DatasetLinks       `json:"dcat:record,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, externalPrefixURL string) *CSVW

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

func NewCustom added in v1.14.0

func NewCustom(m *dataset.Metadata, filterOutputID, downloadServiceURL string) *CSVW

NewCustom returns a CSVW with top level fields populated based on provided metadata for custom datasets

func (*CSVW) AddNotes

func (csvw *CSVW) AddNotes(metadata *dataset.Metadata, targetURL 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,omitempty"`
}

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"`
}

Old fields Contact represents a response model within a dataset

type DatasetLinks struct {
	Editions      Link `json:"editions"`
	LatestVersion Link `json:"latestVersion"`
	Self          Link `json:"self"`
}

New fields

type Download added in v1.6.0

type Download struct {
	HREF string `json:"HREF"`
	Size string `json:"Size"`
}

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is the packages error type

func (Error) Error

func (e Error) Error() string

Error satisfies the standard library Go error interface

func (Error) LogData

func (e Error) LogData() map[string]interface{}

LogData satisfies the dataLogger interface which is used to recover log data from an error

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap implements the standard library Go unwrapper interface

type Link struct {
	HREF string `json:"HREF"`
	ID   string `json:"ID"`
}

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