小编Joh*_*son的帖子

使用Python下载Kaggle数据集

我试图kaggle dataset使用python 下载。但是,通过使用该request方法,我遇到了问题,下载的输出.csv文件是损坏的html文件。

import requests

# The direct link to the Kaggle data set
data_url = 'https://www.kaggle.com/crawford/gene-expression/downloads/actual.csv'

# The local path where the data set is saved.
local_filename = "actsual.csv"

# Kaggle Username and Password
kaggle_info = {'UserName': "myUsername", 'Password': "myPassword"}

# Attempts to download the CSV file. Gets rejected because we are not logged in.
r = requests.get(data_url)

# Login to Kaggle and retrieve the data.
r = requests.post(r.url, data = kaggle_info)

# Writes the …
Run Code Online (Sandbox Code Playgroud)

python download request dataset kaggle

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

标签 统计

dataset ×1

download ×1

kaggle ×1

python ×1

request ×1