diff --git a/st_files_connection/connection.py b/st_files_connection/connection.py index ada62a0..4aff170 100644 --- a/st_files_connection/connection.py +++ b/st_files_connection/connection.py @@ -148,7 +148,7 @@ def _read_csv(path: str | Path, **kwargs) -> pd.DataFrame: if "connection_name" in kwargs: kwargs.pop("connection_name") - with self.open(path, "rt") as f: + with self.open(path, "rt", encoding=kwargs.get("encoding")) as f: return pd.read_csv(f, **kwargs) @cache_data(ttl=ttl, show_spinner="Running `files.read(...)`.") @@ -166,7 +166,7 @@ def _read_json(path: str | Path, **kwargs) -> Any: if "connection_name" in kwargs: kwargs.pop("connection_name") - with self.open(path, "rt") as f: + with self.open(path, "rt", encoding=kwargs.get("encoding")) as f: return json.load(f, **kwargs) @cache_data(ttl=ttl, show_spinner="Running `files.read(...)`.") @@ -175,7 +175,7 @@ def _read_jsonl(path: str | Path, **kwargs) -> pd.DataFrame: kwargs.pop("connection_name") kwargs['lines'] = True - with self.open(path, "rt") as f: + with self.open(path, "rt", encoding=kwargs.get("encoding")) as f: return pd.read_json(f, **kwargs) # Try to infer input_format from file extension if missing