dwca_read: Parse Darwin Core Archive

Description Usage Arguments Details Examples

View source: R/dwca.R

Description

Parse Darwin Core Archive

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## 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))

## End(Not run)

finch documentation built on Aug. 11, 2020, 9:06 a.m.