相关疑难解决方法(0)

递归ftp下载,然后提取gz文件

我有一个多步文件下载过程,我想在R中做.我有中间步骤,但不是第一个和第三个......

# STEP 1 Recursively find all the files at an ftp site 
# ftp://prism.oregonstate.edu//pub/prism/pacisl/grids
all_paths <- #### a recursive listing of the ftp path contents??? ####

# STEP 2 Choose all the ones whose filename starts with "hi"
all_files <- sapply(sapply(strsplit(all_paths, "/"), rev), "[", 1)
hawaii_log <- substr(all_files, 1, 2) == "hi"
hi_paths <- all_paths[hawaii_log]
hi_files <- all_files[hawaii_log]

# STEP 3 Download & extract from gz format into a single directory
mapply(download.file, url = hi_paths, destfile = hi_files)
## …
Run Code Online (Sandbox Code Playgroud)

r

3
推荐指数
2
解决办法
6682
查看次数

标签 统计

r ×1