Skip to content

Commit

Permalink
Added header info
Browse files Browse the repository at this point in the history
  • Loading branch information
nareal committed May 13, 2021
1 parent 3612029 commit a648ee5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/download_french_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ download_french_data <- function(dataset_name,
assertthat::assert_that(NROW(url_info) == 1,
msg = "There are more than one match to the data set name, please verify the contents of the parameter `dataset_name`")


link_to_file <- paste0(base_url, url_info$file_url[1])

temp_file_name <- fs::file_temp(pattern =
Expand Down Expand Up @@ -201,6 +200,12 @@ download_french_data <- function(dataset_name,
dplyr::summarise(start = dplyr::first(.data$line) - 1,
end = dplyr::last(.data$line))

header_info <-
readr::read_lines(file_content,
n_max = subsets$start[1] - 3) %>%
stringr::str_trim(side = "both") %>%
paste(collapse = " ")

subsets <- subsets %>%
dplyr::mutate(
name = purrr::map_chr(.data$start - 2, read_info,
Expand Down Expand Up @@ -245,7 +250,7 @@ download_french_data <- function(dataset_name,
} else {
results <-
structure(list(
info = paste(
info = paste(header_info, "\n\n",
"Information collected from:",
link_to_file,
"on",
Expand Down

0 comments on commit a648ee5

Please sign in to comment.