in coll/mc_sim_coll_blog.py [0:0]
def list_csv_files(bucket_name, folder_name=""):
""" List all CSV files in a given folder in S3 bucket
:param bucket_name: Bucket in which CSV files is located
:param folder_name: Folder in bucket in which CSV files reside
:return: List of names of CSV files in given bucket
"""
files = []
s3 = boto3.client('s3')
for f in s3.list_objects_v2(Bucket=bucket_name, Prefix=folder_name)["Contents"]:
# only get CSV files
if f["Key"].split('.')[-1] == 'csv':
files.append(f["Key"])
# endif
# endfor #
return files