Created
June 24, 2021 05:42
-
-
Save 1pha/2d551d4c3d7e6af6bb27efbe7a6308a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from io import BytesIO, StringIO | |
from urllib.request import urlopen | |
from zipfile import ZipFile | |
import pandas as pd | |
def download_and_unzip(url, extract_to='.'): | |
http_response = urlopen(url) | |
zipfile = ZipFile(BytesIO(http_response.read())) | |
return zipfile | |
### YOUR URL | |
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/00526/data.zip" | |
zipped_data = download_and_unzip(url) | |
### CUSTOMIZE BELOW | |
fname = zipped_data.namelist()[0] | |
df = pd.read_csv(StringIO(zipped_data.read(fname).decode('utf-8'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment