繁体   English   中英

使用R下载并解压缩包含文件夹的zip文件

[英]Using R to Download and extract zip file that contains a folder

在Rstudio中,我写道:

urlcoP <- "http://www.cophieu68.vn/datax123456/metastock_all_data.zip"
temp <- tempfile()
download.file(urlcoP,temp)
data <- read.table(unz(temp, "metastock_all_data.txt"))

但是它得到了错误:

Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
  cannot locate file 'metastock_all_data.txt' in zip file 'C:\TEMP\RtmpaaH3PW\file135c1e97348'

其原因是, metastock_all_data.txt是一个文件夹,名为在datax123456的拉链。

尝试这个?

data <- read.table(unz(temp, "datax123456/metastock_all_data.txt"))

metastock_all_data.txt在zip中名为datax123456的文件夹中,因此将文件夹添加到metastock_all_data.txt之前

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM