diff --git a/src/unitxt/loaders.py b/src/unitxt/loaders.py index 2db97abe5d..db74b974ca 100644 --- a/src/unitxt/loaders.py +++ b/src/unitxt/loaders.py @@ -457,8 +457,8 @@ def split_generator(self, split: str) -> Generator: except ValueError: import fsspec - with fsspec.open(file, mode="rt") as file: - dataframe = self.read_dataframe(file) + with fsspec.open(file, mode="rt") as f: + dataframe = self.read_dataframe(f) break except Exception as e: logger.warning(f"Attempt load {attempt + 1} failed: {e}") @@ -539,8 +539,7 @@ def read_dataframe(self, file) -> pd.DataFrame: if self.column_names is not None: args["names"] = self.column_names args["header"] = None # Don't use first row as header - if self.indirect_read: - # Open the URL with urllib first to mitigate HTTP errors that sometime happen with the internal pandas implementation + if self.indirect_read and isinstance(file, str): from urllib import request with request.urlopen(file) as response: