Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: parse into dataframe using pandas #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ucimlrepo/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import urllib.parse
import certifi
import ssl
from io import BytesIO

from ucimlrepo.dotdict import dotdict

Expand Down Expand Up @@ -96,7 +97,14 @@ def fetch_ucirepo(
try:
df = pd.read_csv(data_url)
except (urllib.error.URLError, urllib.error.HTTPError):
raise DatasetNotFoundError('Error reading data csv file for "{}" dataset (id={}).'.format(name, id))
try:
response_data=urllib.request.urlopen(data_url, context=ssl.create_default_context(cafile=certifi.where()))
data_byte = response_data.read()
df = pd.read_csv(BytesIO(data_byte))
except:
raise DatasetNotFoundError('Error reading data csv file for "{}" dataset (id={}).'.format(name, id))
else:
pass

if df.empty:
raise DatasetNotFoundError('Error reading data csv file for "{}" dataset (id={}).'.format(name, id))
Expand Down