Skip to content
Merged
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
28 changes: 15 additions & 13 deletions sklearn/datasets/_openml.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,19 +519,21 @@ def _open_url_and_load_gzip_file(url, data_home, n_retries, delay, arff_params):
url, data_home, n_retries, delay, arff_params
)
except Exception as exc:
if parser == "pandas":
from pandas.errors import ParserError

if isinstance(exc, ParserError):
# A parsing error could come from providing the wrong quotechar
# to pandas. By default, we use a double quote. Thus, we retry
# with a single quote before to raise the error.
arff_params["read_csv_kwargs"] = {"quotechar": "'"}
X, y, frame, categories = _open_url_and_load_gzip_file(
url, data_home, n_retries, delay, arff_params
)
else:
raise
if parser != "pandas":
raise

from pandas.errors import ParserError

if not isinstance(exc, ParserError):
raise

# A parsing error could come from providing the wrong quotechar
# to pandas. By default, we use a double quote. Thus, we retry
# with a single quote before to raise the error.
arff_params["read_csv_kwargs"] = {"quotechar": "'"}
X, y, frame, categories = _open_url_and_load_gzip_file(
url, data_home, n_retries, delay, arff_params
)

return X, y, frame, categories

Expand Down