I have an S3 bucket. Inside the bucket, we have a folder for the year, 2018, and some files we have collected for each month and day. So, as an example, 2018\3\24, 2018\3\25 so forth and so on.
We didn't put the dates in the files inside each days bucket.
Basically, I want to iterate through the bucket and use the folders structure to classify each file by it's 'date' since we need to load it into a different database and will need a way to identify.
I've read a ton of posts on using boto3, and iterating through however there seem to be conflicting details on if what I need can be done.
If there's an easier way of doing this please suggest.
I got it close import boto3
s3client = boto3.client('s3')
bucket = 'bucketname'
startAfter = '2018'
s3objects= s3client.list_objects_v2(Bucket=bucket, StartAfter=startAfter )
for object in s3objects['Contents']:
print(object['Key'])