dpaddwriter: Add a writer function for a specific format

View source: R/dpaddwriteer.R

dpaddwriterR Documentation

Add a writer function for a specific format

Description

Add a writer function for a specific format

Usage

dpaddwriter(format, writer)

Arguments

format

the data format read by the writer Should be a length 1 character vector.

writer

the writer function. See details.

Details

Adds a writer for a given format. The writer is added to a list of writers referenced by the format. The writer function should accept 'data' with the data as its first argument, 'resourcename' the name of the resource to which the data set belongs, 'datapackage' that datapackage to which the data should be written.

Note that adding a writer for an existing format will overwrite the existing writer

Value

Does not return anything (invisible(NULL)).

Examples

# Add a very simple writer for json
json_writer <- function(data, resourcename, datapackage, ...) {
  dataresource <- dpresource(datapackage, resourcename)
  path <- dppath(dataresource, fullpath = TRUE)
  jsonlite::write_json(data, path)
}

dpaddwriter("json", json_writer)


djvanderlaan/datapackage documentation built on March 18, 2024, 4:57 p.m.