Loading data from AWS S3 for a Dash App

I am using Dash in Amazon Web Services. I would be very happy to have some hints on how to load data from a S3 bucket for my Dash App. I was thinking about using Boto3, but I am not sure if this provides a solution without saving the file first to local disk, which I do not want. Thank you very much in advance for your suggestions !

There should be a method in boto3 to download without saving to disk if I remember right. Otherwise you could put cloudfront in front of the bucket and load with requests.

1 Like

import io
import pandas as pd
import boto3
from botocore.client import Config

client = boto3.client(
‘s3’,
aws_access_key_id=‘yourid’,
aws_secret_access_key=‘yourkey’,
config=Config(signature_version=‘s3v4’))

obj = client.get_object(Bucket=‘yourbucket’, Key=‘yourkey’)
df = pd.read_csv(io.BytesIO(obj[‘Body’].read()))

1 Like