πͺSet up S3 data retrieval
Here is sample code to retrieve data from Index One's S3 bucket in Python.
Last updated
Here is sample code to retrieve data from Index One's S3 bucket in Python.
Last updated
import boto3
access_key = "xxxxxxxxxxxxxxxxxxxx"
secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bucket_name = "prod-core-i1-export"
team_directory = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/"
session = boto3.Session(
aws_access_key_id=access_key,
aws_secret_access_key=secret
)
s3_client = session.client("s3")
r = s3_client.list_objects_v2(
Bucket=bucket_name,
Prefix=team_directory
)
for object in r['Contents']:
s3_client.download_file(
bucket_name,
object['Key'],
'/my/local/dir/filename.csv'
)