Skip to contents

[Stable]

Usage

attachment_link(data_tbl, form_schema, att_path = "media")

Arguments

data_tbl

The downloaded submissions from submission_export read into a tibble by readr::read_csv.

form_schema

The form_schema for the submissions. E.g. the output of ruODK::form_schema().

att_path

A local path, default: "media" (as per .csv.zip export). Selected columns of the dataframe (containing attchment filenames) are prefixed with att_path, thus turning them into relative paths.

Value

The dataframe with attachment columns modified to contain relative paths to the downloaded attachment files.

Examples

if (FALSE) { # \dontrun{
t <- tempdir()
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")

# Predict filenames (with knowledge of form)
fid <- get_default_fid()
fid_csv <- fs::path(t, glue::glue("{fid}.csv"))
fid_csv_tae <- fs::path(t, glue::glue("{fid}-taxon_encounter.csv"))
fs <- form_schema()

# Download the zip file
se <- ruODK::submission_export(
  local_dir = t,
  overwrite = FALSE,
  verbose = TRUE
)

# Unpack the zip file
f <- unzip(se, exdir = t)
fs::dir_ls(t)

# Prepend attachments with media/ to turn into relative file paths
data_quadrat <- fid_csv %>%
  readr::read_csv(na = c("", "NA", "na")) %>%
  janitor::clean_names() %>%
  handle_ru_datetimes(fs) %>%
  attachment_link(fs)
} # }