Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
azeemsaifi
New Member

Connect AWS S3 with Power BI using Python

Hi Team,

I’m looking to connect AWS S3 with Power BI using Python, and I need some guidance on how to achieve this.

If anyone has experience or can share a step-by-step solution, I’d really appreciate your help. This is quite urgent for my current project.

 

Looking forward to your suggestions.

Thanks in advance!

1 ACCEPTED SOLUTION
johnbasha33
Super User
Super User

@azeemsaifi 

You’ll need to use boto3 to connect to your S3 bucket.

import boto3
import pandas as pd
from io import StringIO # or BytesIO for binary files like Excel

# Set up AWS credentials (ideally, use IAM roles or environment variables)
aws_access_key = "YOUR_ACCESS_KEY"
aws_secret_key = "YOUR_SECRET_KEY"
bucket_name = "your-bucket-name"
file_key = "folder/yourfile.csv" # S3 object key (path)

# Connect to S3
s3 = boto3.client('s3', aws_access_key_id=aws_access_key,
aws_secret_access_key=aws_secret_key)

# Get the file object
response = s3.get_object(Bucket=bucket_name, Key=file_key)
data = response['Body'].read().decode('utf-8') # for CSV

# Load to pandas
df = pd.read_csv(StringIO(data))
print(df.head())


Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!



View solution in original post

5 REPLIES 5
v-ssriganesh
Community Support
Community Support

Hi @azeemsaifi,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-ssriganesh
Community Support
Community Support

Hi @azeemsaifi,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-ssriganesh
Community Support
Community Support

Hi @azeemsaifi,
Thank you for reaching out to the Microsoft Fabric Community Forum.

The solution shared by @johnbasha33is spot-on for connecting AWS S3 to Power BI using Python.

If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

Hi @azeemsaifi,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.
Thank you.

johnbasha33
Super User
Super User

@azeemsaifi 

You’ll need to use boto3 to connect to your S3 bucket.

import boto3
import pandas as pd
from io import StringIO # or BytesIO for binary files like Excel

# Set up AWS credentials (ideally, use IAM roles or environment variables)
aws_access_key = "YOUR_ACCESS_KEY"
aws_secret_key = "YOUR_SECRET_KEY"
bucket_name = "your-bucket-name"
file_key = "folder/yourfile.csv" # S3 object key (path)

# Connect to S3
s3 = boto3.client('s3', aws_access_key_id=aws_access_key,
aws_secret_access_key=aws_secret_key)

# Get the file object
response = s3.get_object(Bucket=bucket_name, Key=file_key)
data = response['Body'].read().decode('utf-8') # for CSV

# Load to pandas
df = pd.read_csv(StringIO(data))
print(df.head())


Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!



Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.