MLhacker
MLhacker

Reputation: 1502

How to use Python Web Scraping to download CSV file then convert it to Pandas Dataframe?

I'd like my script to do the following:

1) Access this website:
2) Import a CSV file titled "Sales Data with Leading Indicator"
3) Convert it to pandas Dataframe for data analysis.

Currently, the code I have is this:

response = request.urlopen("http://vincentarelbundock.github.io/Rdatasets/datasets.html") 
csv = response.read()

Thanks in advance

Upvotes: 0

Views: 3867

Answers (1)

DeepSpace
DeepSpace

Reputation: 81594

pandas.read_csv() method accepts a URL to a csv file as its buffer, so

import pandas as pd
pd.read_csv('http://vincentarelbundock.github.io/Rdatasets/csv/datasets/BJsales.csv')

Should basically work. See further info here .

Upvotes: 4

Related Questions