Nothing
#' @importFrom tools file_path_sans_ext file_ext
nops_zip2tab <- function(file = "nops_eval.zip")
{
## input .zip file and output .tab file
if(tools::file_ext(file) != "zip") stop("'file' must be a .zip file")
out <- paste0(file_path_sans_ext(file), ".tab")
## create temporary directory
tdir <- tempfile()
dir.create(tdir)
## copy zip file and unzip
file.copy(file, file.path(tdir, file))
odir <- getwd()
setwd(tdir)
utils::unzip(file)
## student accounts
acc <- dir(pattern = "^c")
## extract relevant HTML table
html <- function(x) {
y <- dir(x, pattern = "\\.html$", full.names = TRUE)
y <- readLines(y)
y <- y[(grep("<body>", y) + 1):(grep("<h3>Prüfungsbeleg</h3>", y) - 1)]
sprintf("%s\t%s", x, paste(y, collapse = ""))
}
tab <- sapply(acc, html)
## create tab file in original directory
setwd(odir)
unlink(tdir)
writeLines(tab, out)
invisible(tab)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.