Intermediate Importing Data in Python
Hugo Bowne-Anderson
Data Scientist at DataCamp
Flat files such as .txt and .csv
Pickled files, Excel spreadsheets, and many others!
Data from relational databases
You can do all these locally
What if your data is online?
Import and locally save datasets from the web
Load datasets into pandas DataFrames
Make HTTP requests (GET requests)
Scrape web data such as HTML
Parse HTML into useful data (BeautifulSoup)
Use the urllib and requests packages
urlopen()
- accepts URLs instead of file namesfrom urllib.request import urlretrieve
url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/
winequality-white.csv'
urlretrieve(url, 'winequality-white.csv')
('winequality-white.csv', <http.client.HTTPMessage at 0x103cf1128>)
Intermediate Importing Data in Python