Skip to content

ENH Recognize 's3n' and 's3a' as an S3 address #11071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2015
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ Other enhancements

- ``pd.read_csv`` can now read bz2-compressed files incrementally, and the C parser can read bz2-compressed files from AWS S3 (:issue:`11070`, :issue:`11072`).

- In ``pd.read_csv``, recognize "s3n://" and "s3a://" URLs as designating S3 file storage (:issue:`11070`, :issue:`11071`).

.. _whatsnew_0170.api:

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def _is_url(url):


def _is_s3_url(url):
"""Check for an s3 url"""
"""Check for an s3, s3n, or s3a url"""
try:
return parse_url(url).scheme == 's3'
return parse_url(url).scheme in ['s3', 's3n', 's3a']
except:
return False

Expand Down
16 changes: 16 additions & 0 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4253,6 +4253,22 @@ def test_parse_public_s3_bucket(self):
nt.assert_false(df.empty)
tm.assert_frame_equal(pd.read_csv(tm.get_data_path('tips.csv')), df)

@tm.network
def test_parse_public_s3n_bucket(self):
# Read from AWS s3 as "s3n" URL
df = pd.read_csv('s3n://pandas-test/tips.csv', nrows=10)
self.assertTrue(isinstance(df, pd.DataFrame))
self.assertFalse(df.empty)
tm.assert_frame_equal(pd.read_csv(tm.get_data_path('tips.csv')).iloc[:10], df)

@tm.network
def test_parse_public_s3a_bucket(self):
# Read from AWS s3 as "s3a" URL
df = pd.read_csv('s3a://pandas-test/tips.csv', nrows=10)
self.assertTrue(isinstance(df, pd.DataFrame))
self.assertFalse(df.empty)
tm.assert_frame_equal(pd.read_csv(tm.get_data_path('tips.csv')).iloc[:10], df)

@tm.network
def test_s3_fails(self):
import boto
Expand Down