-
Notifications
You must be signed in to change notification settings - Fork 12
/
attachment_link.Rd
85 lines (79 loc) · 2.63 KB
/
attachment_link.Rd
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/attachment_link.R
\name{attachment_link}
\alias{attachment_link}
\title{Prefix attachment columns from CSV export with a local attachment file path.}
\usage{
attachment_link(data_tbl, form_schema, att_path = "media")
}
\arguments{
\item{data_tbl}{The downloaded submissions from
\code{\link{submission_export}} read into a \code{tibble} by
\code{readr::read_csv}.}
\item{form_schema}{The \code{form_schema} for the submissions.
E.g. the output of \code{ruODK::form_schema()}.}
\item{att_path}{A local path, default: "media" (as per .csv.zip export).
Selected columns of the dataframe (containing attchment filenames) are
prefixed with \code{att_path}, thus turning them into relative paths.}
}
\value{
The dataframe with attachment columns modified to contain relative
paths to the downloaded attachment files.
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
\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)
}
}
\seealso{
Other utilities:
\code{\link{attachment_get}()},
\code{\link{attachment_url}()},
\code{\link{drop_null_coords}()},
\code{\link{form_schema_parse}()},
\code{\link{get_one_attachment}()},
\code{\link{get_one_submission}()},
\code{\link{get_one_submission_att_list}()},
\code{\link{get_one_submission_audit}()},
\code{\link{handle_ru_attachments}()},
\code{\link{handle_ru_datetimes}()},
\code{\link{handle_ru_geopoints}()},
\code{\link{handle_ru_geoshapes}()},
\code{\link{handle_ru_geotraces}()},
\code{\link{isodt_to_local}()},
\code{\link{odata_submission_rectangle}()},
\code{\link{predict_ruodk_name}()},
\code{\link{prepend_uuid}()},
\code{\link{split_geopoint}()},
\code{\link{split_geoshape}()},
\code{\link{split_geotrace}()},
\code{\link{strip_uuid}()},
\code{\link{tidyeval}},
\code{\link{unnest_all}()}
}
\concept{utilities}