Learn R Programming

finch (version 0.4.0)

dwca_read: Parse Darwin Core Archive

Description

Parse Darwin Core Archive

Usage

dwca_read(input, read = FALSE, ...)

Arguments

input

(character) Path to local zip file, directory, or a url. If a URL it must be for a zip file.

read

(logical) Whether or not to read in data files. If FALSE, we give back paths to files only. Default: FALSE

...

Further args passed on to data.table::fread()

Details

Note that sometimes file reads fail. We use data.table::fread() internally, which is very fast, but can fail sometimes. If so, try reading in the data manually.

When you pass in a URL, we use rappdirs to determine cache path, and if you pass the same URL again, and your cache is not cleared, we'll pull from the cache. Passing a file or directory on your local system won't invoke the caching route, but will go directly to the file/directory.

Examples

Run this code
# NOT RUN {
# set up a temporary directory for the example
dwca_cache$cache_path_set(path = "finch", type = "tempdir")

dir <- system.file("examples", "0000154-150116162929234", package = "finch")

# Don't read data in
(x <- dwca_read(dir, read=FALSE))
x$files
x$highmeta
x$dataset_meta[[1]]
x$data

# Read data
(x <- dwca_read(dir, read=TRUE))
head(x$data[[1]])

# Can pass in a zip file
zip <- system.file("examples", "0000154-150116162929234.zip",
  package = "finch")
(out <- dwca_read(zip))
out$files
out$highmeta
out$emlmeta
out$dataset_meta

# Can pass in zip file as a url
url <-
"https://github.com/ropensci/finch/blob/master/inst/examples/0000154-150116162929234.zip?raw=true"
(out <- dwca_read(url))

# another url
url <- "http://ipt.jbrj.gov.br/jbrj/archive.do?r=redlist_2013_taxons&v=3.12"
(out <- dwca_read(url))
# }

Run the code above in your browser using DataLab