Skip to content

Commit 5600c45

Browse files
committed
fix s3 url
1 parent 4e6cde7 commit 5600c45

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pandas/io/common.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,7 @@ def iterdir(
13431343
path: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str],
13441344
extensions: str | Iterable[str] | None = None,
13451345
glob: str | None = None,
1346+
storage_options: StorageOptions | None = None,
13461347
) -> list[FilePath] | ReadCsvBuffer[bytes] | ReadCsvBuffer[str]:
13471348
"""Yield file paths in a directory (no nesting allowed).
13481349
@@ -1430,7 +1431,15 @@ def iterdir(
14301431

14311432
# Remote paths
14321433
fsspec = import_optional_dependency("fsspec", extra=scheme)
1433-
fs, inner_path = fsspec.core.url_to_fs(path_str)
1434+
1435+
# GH #11071
1436+
# Two legacy S3 protocols (s3n and s3a) are replaced with s3
1437+
if path_str.startswith("s3n://"):
1438+
path_str = path_str.replace("s3n://", "s3://")
1439+
if path_str.startswith("s3a://"):
1440+
path_str = path_str.replace("s3a://", "s3://")
1441+
1442+
fs, inner_path = fsspec.core.url_to_fs(path_str, **storage_options)
14341443
if fs.isfile(inner_path):
14351444
path_obj = PurePosixPath(inner_path)
14361445
if _match_file(

pandas/io/parsers/readers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,8 @@ def _read(
727727

728728
extensions = kwds.get("extensions", None)
729729
glob = kwds.get("glob", None)
730-
files = iterdir(filepath_or_buffer, extensions, glob)
730+
storage_options = kwds.get("storage_options", None)
731+
files = iterdir(filepath_or_buffer, extensions, glob, storage_options)
731732

732733
if isinstance(files, list) and not files:
733734
raise FileNotFoundError(

0 commit comments

Comments
 (0)