I have a use case where I have to read tables names under a folder on an Amazon S3 given a path.
e.g say a bucket with path s3://mybucket/aws glue service/raw/source_data/
in source data there's a folder named Tables that list table names. eg.
Tables:
- users
- customers
- Admin
so basically I want to write a function that returns ["users","customers","Admin"]
Here's what I have so far:
def read_tables(path):
tables = []
s3 = boto3.resource('s3')
bucket = s3.Bucket(path)
for obj in bucket.objects.filter(Prefix='Tables/'):
tables.append(obj)
return tables