简体   繁体   English

如何将Dropbox CSV文件下载到熊猫

[英]How to download dropbox csv file to pandas

I'm unfamiliar with webscraping. 我不熟悉网络抓取。 I found some instructions, but I'm not sure what else to do from here. 我找到了一些说明,但是我不确定从这里可以做什么。 Clicking on the link downloads the csv file automatically. 单击链接会自动下载csv文件。 How do I get it to my pandas jupyter notebook by webscraping? 如何通过网络抓取将其保存到我的大熊猫Jupyter笔记本中?

import urllib.request
url = 'https://www.dropbox.com/s/.../movie_data.csv'
u = urllib.request.urlopen(url)
data = u.read()
u.close()

with open('movie_data.csv', "wb") as f :
   f.write(data)

Figured it out. 弄清楚了。 You need to append < ?dl=1 > to the end of your url like so: 您需要将<?dl = 1>附加到网址末尾,如下所示:

df = pd.read_csv("https://www.dropbox.com/s/asdfasdfasfasdf/movie_data.csv?dl=1")

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

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