简体   繁体   中英

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. How do I get it to my pandas jupyter notebook by webscraping?

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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