简体   繁体   中英

Run a Python script on S3 Files

I want to run a python script on my entire S3 Bucket. The script takes the files and inserts them into a csv file.

how can I run on the S3 files like a local script does? using "python https://s3url/ " doesn't work for me.

You can use boto3 to get the list of all the files in s3 bucket:

import boto3

bucketName = "Your S3 BucketName"

# Create an S3 client
s3 = boto3.client('s3')

for key in s3.list_objects(Bucket=bucketName)['Contents']: 
    print(key['Key'])

A good idea would be to use boto3 . Here is a simple guide on how to use the module

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM