Skip to content

Instantly share code, notes, and snippets.

@tonyelhabr
Last active June 3, 2022 01:02
Show Gist options
  • Save tonyelhabr/691b30288c0d5709def864fedbf64757 to your computer and use it in GitHub Desktop.
Save tonyelhabr/691b30288c0d5709def864fedbf64757 to your computer and use it in GitHub Desktop.
Read .qs file from a URL
qs_from_url <- function(url){
load <- try(curl::curl_fetch_memory(url), silent = TRUE)
if (inherits(load, "try-error")) {
cli::cli_warn("Failed to retrieve data from {.url {url}}")
return(data.frame())
}
content <- try(qs::qdeserialize(load$content), silent = TRUE)
if (inherits(content, "try-error")) {
cli::cli_warn("Failed to parse file with {.fun qs::qdeserialize()} from {.url {url}}")
rlang::check_installed(
pkg = c("Rcpp (>= 1.0.8)","RcppParallel (>= 5.1.5)"),
reason = "- updating these packages frequently resolves qs-related issues.")
return(data.frame())
}
return(content)
}
url <- "https://github.com/JaseZiv/worldfootballR_data/blob/master/data/match_results/ARG_match_results.qs?raw=true"
qs_from_url(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment