Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To use Pandas to display a list of all csv files in an s3 bucket, you can use the following code:

import pandas as pd
import boto3

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

# List all objects in the bucket
objects = s3.list_objects(Bucket='your_bucket_name')

# Filter the list to include only csv files
csv_files = [file['Key'] for file in objects['Contents'] if file['Key'].endswith('.csv')]

# Convert the list of csv file names to a pandas DataFrame
df = pd.DataFrame(csv_files, columns=['File Name'])

# Display the DataFrame
print(df)

Note that you will need to replace "yourbucketname" with the actual name of the s3 bucket you want to use.