Reputation: 19395
I have a list of files such as
mylist <- c('http://myweb/myzip1.gz',
'http://myweb/myzip2.gz',
'http://myweb/myzip3.gz)
I need to download them and unzip them to another path D://mydata/
.
Right now, I have used purrr
and download.file
#get files
myfunc <- function(mystring){
download.file(mystring,
destfile = paste0('D://mydata/', basename(mystring))
}
#download data
map(mylist, myfunc)
but after a few hours of downloads (each file is 10GB+), Rstudio
freezes (even though the downloads still occur in the background).
Is there are more efficient way? I would like to keep track of the downloads in R without having to freeze at some point.
Thanks!
Upvotes: 0
Views: 396
Reputation: 1279
I don't think the info above is enough to give 'an answer' as a single code chunk, but I think there are a few things you could do that, collectively would solve the problem:
seq_along(mylist) %/% N
, where N is the chunk size. Consider using a for loop for iterating between batches, and purrr
only within the batches. gc()
to remove them from RAM. Upvotes: 2