从 Kaggle 读取数据集
Read dataset from Kaggle
我正在尝试使用以下命令将数据从 Kaggle 下载到 R 中。我尝试下载的数据集位于 here。
library(httr)
dataset <- GET("https://www.kaggle.com/api/v1/competitions/data/download/10445/train.csv",
authenticate(username, authkey, type = "basic"))
变量dataset
的类型为"application/zip"
。有人可以帮我从 link 中获取 csv 文件吗?(我使用 http_type(train)
如果我的问题不清楚,请告诉我
编辑:包含基于评论的库名称。
我根据 here 发布的答案找到了解决方案。有人在评论中发布了 link,但我再也看不到评论了。谢谢好撒玛利亚人!
library(httr)
dataset <- httr::GET("https://www.kaggle.com/api/v1/competitions/data/download/10445/train.csv",
httr::authenticate(username, authkey, type = "basic"))
temp <- tempfile()
download.file(dataset$url,temp)
data <- read.csv(unz(temp, "train.csv"))
unlink(temp)
我正在尝试使用以下命令将数据从 Kaggle 下载到 R 中。我尝试下载的数据集位于 here。
library(httr)
dataset <- GET("https://www.kaggle.com/api/v1/competitions/data/download/10445/train.csv",
authenticate(username, authkey, type = "basic"))
变量dataset
的类型为"application/zip"
。有人可以帮我从 link 中获取 csv 文件吗?(我使用 http_type(train)
如果我的问题不清楚,请告诉我
编辑:包含基于评论的库名称。
我根据 here 发布的答案找到了解决方案。有人在评论中发布了 link,但我再也看不到评论了。谢谢好撒玛利亚人!
library(httr)
dataset <- httr::GET("https://www.kaggle.com/api/v1/competitions/data/download/10445/train.csv",
httr::authenticate(username, authkey, type = "basic"))
temp <- tempfile()
download.file(dataset$url,temp)
data <- read.csv(unz(temp, "train.csv"))
unlink(temp)