Skip to main content

Added v0.5

The S3 connector supports writing files to & from a bucket as well as uploading/downloading.

Tabset

Read​

Recipe​

read:
- s3:
bucket: bucket
key: key
access_key: access_key
secret_access_key: secret_access_key

Function​

from wrangles.connectors import s3
df = s3.read(
bucket='bucket',
key='key',
access_key='access_key',
secret_access_key='secret_access_key'
)

Parameters​

The S3 connector also supports the same optional parameters as the file connector. See the file connector for more details.

ParameterRequiredData TypeNotes
bucket✓strThe name of the bucket to download object from
key✓strThe name of the key to download from
access_code✓strS3 access key
secret_access_code✓strS3 secret access key
order_bystrUses SQL syntax to sort the input.
ifstrA condition that will determine whether the action runs or not as a whole.

Write​

Recipe​

write:
- s3:
bucket: bucket
key: key
access_key: access_key
secret_access_key: secret_access_key

Function​

from wrangles.connectors import s3

df = Imagine a Dataframe

s3.write(
df,
bucket='bucket',
key='key',
access_key='access_key',
secret_access_key='secret_access_key'
)

Parameters​

The S3 connector also supports the same optional parameters as the file connector. See the file connector for more details.

ParameterRequiredData TypeNotes
df✓DataFrameFunction only. DataFrame of contents to write to the S3 bucket
bucket✓strThe name of the bucket where file will be written
key✓strThe name of the key to download from
access_key✓strS3 access key
secret_access_key✓strS3 secret access key
order_bystrUses SQL syntax to sort the output.
ifstrA condition that will determine whether the action runs or not as a whole.

Upload​

Recipe​

run:
on_success:
- s3.upload_files:
bucket: s3-bucket
file: example.csv

Function​

from wrangles.connectors import s3
s3.upload_files.run(
bucket='bucket',
file = 'example.csv',
key='key'
)

Parameters​

ParameterRequiredData TypeNotes
bucket✓strThe name of the S3 bucket where file will be written
file✓str, listFile or list of files to upload
keystr, listS3 file key or list of keys to upload as, defaults to None
endpoint_urlstrOverride the S3 host for alternative S3 storage providers
aws_access_key_idstrSet the access key. Can also be set as an environment variable
aws_secret_access_keystrSet the access secret. Can also be set as an environment variable
ifstrA condition that will determine whether the action runs or not as a whole.

Download​

Recipe​

run:
on_start:
- s3.download_files:
bucket: s3-bucket
key: example.csv

Function​

from wrangles.connectors import s3
df = s3.download_files.run(
bucket='bucket',
key='key'
file = 'example.csv',
)

Parameters​

ParameterRequiredData TypeNotes
bucket✓strThe name of the S3 bucket where file will be written
key✓str, listS3 file key or list of keys to download
filestr, listLocal filename or list of filenames to save the downloaded files as, defaults to None
endpoint_urlstrOverride the S3 host for alternative S3 storage providers
aws_access_key_idstrSet the access key. Can also be set as an environment variable
aws_secret_access_keystrSet the access secret. Can also be set as an environment variable
ifstrA condition that will determine whether the action runs or not as a whole.