Skip to content

Instantly share code, notes, and snippets.

@1pha
Created June 24, 2021 05:42
Show Gist options
  • Save 1pha/2d551d4c3d7e6af6bb27efbe7a6308a1 to your computer and use it in GitHub Desktop.
Save 1pha/2d551d4c3d7e6af6bb27efbe7a6308a1 to your computer and use it in GitHub Desktop.
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