diff --git a/src/datasets/download/streaming_download_manager.py b/src/datasets/download/streaming_download_manager.py index 861aec0c746..aa6a6934a73 100644 --- a/src/datasets/download/streaming_download_manager.py +++ b/src/datasets/download/streaming_download_manager.py @@ -660,8 +660,7 @@ def xpandas_read_csv(filepath_or_buffer, use_auth_token: Optional[Union[str, boo if hasattr(filepath_or_buffer, "read"): return pd.read_csv(filepath_or_buffer, **kwargs) else: - with xopen(filepath_or_buffer, "rb", use_auth_token=use_auth_token) as f: - return pd.read_csv(f, **kwargs) + return pd.read_csv(xopen(filepath_or_buffer, "rb", use_auth_token=use_auth_token), **kwargs) def xpandas_read_excel(filepath_or_buffer, **kwargs):