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

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
anurag_aryan
New Member

Error while writing PySpark code to load the csv file data into a dataframe

Hi,

 

I'm new to PySpark. While writing PySpark code, to load the csv file data into a dataframe, I'm getting following error -

PySpark error.png

Here is my code -

Pyspark code.png

Here is my lake house -

Lakehouse.png

 

Please suggest.

Thanks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-veshwara-msft
Community Support
Community Support

Hi @anurag_aryan 

Thanks for using Microsoft Fabric Community.
The error you are facing is likely due to there is no Lakehouse attached to the Notebook. 
From the images , in the Explorer pane under Resources there is no Lakehouse added.

vveshwaramsft_3-1738239838256.png

Please add the Lakehouse where the CSV file exists and retry.

Alternatively, you can include the ABFS path in the code to avoid attaching the Lakehouse.:
Here is the updated code:

from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("CSV Reader").getOrCreate()
# ABFS Path for the file
abfs_path = "Your ABFS path here"
df = spark.read.format("csv") \
    .option("header", "true") \
    .load(abfs_path)
display(df.limit(10)

To obtain the ABFS path for the CSV file:
Navigate to Lakehouse ->  Files -> data -> products.csv, then check the properties of the csv to copy the ABFS path.

Hope it works.
If this post helps please accept as solution to help others find it and a kudos would be appreciated.

Best Regards,
Vinay

View solution in original post

4 REPLIES 4
v-veshwara-msft
Community Support
Community Support

Hi @anurag_aryan ,

We just wanted to follow up one last time to check if the issue has been resolved on your end. If you’re still encountering issues or need any further assistance, please don’t hesitate to reach out—we’re always happy to help.

Best regards,
Vinay.

v-veshwara-msft
Community Support
Community Support

Hi @anurag_aryan ,

We just wanted to check in again regarding your issue. If you’ve found a solution, marking the reply as the solution and leaving a kudos would be greatly appreciated—it helps the community and others with similar questions.

If you’re still facing challenges or have further questions, please let us know—we’re here to help and would love to assist you in resolving this.

Looking forward to hearing back from you!

Best regards,
Vinay.

v-veshwara-msft
Community Support
Community Support

Hi @anurag_aryan ,
We haven’t heard back since our last response and wanted to check if your query has been resolved. If not, please feel free to reach out for further assistance. If it has been resolved, kindly mark the helpful reply as the solution to make it easier for others to find. A kudos would also be greatly appreciated!
Thank you.

v-veshwara-msft
Community Support
Community Support

Hi @anurag_aryan 

Thanks for using Microsoft Fabric Community.
The error you are facing is likely due to there is no Lakehouse attached to the Notebook. 
From the images , in the Explorer pane under Resources there is no Lakehouse added.

vveshwaramsft_3-1738239838256.png

Please add the Lakehouse where the CSV file exists and retry.

Alternatively, you can include the ABFS path in the code to avoid attaching the Lakehouse.:
Here is the updated code:

from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("CSV Reader").getOrCreate()
# ABFS Path for the file
abfs_path = "Your ABFS path here"
df = spark.read.format("csv") \
    .option("header", "true") \
    .load(abfs_path)
display(df.limit(10)

To obtain the ABFS path for the CSV file:
Navigate to Lakehouse ->  Files -> data -> products.csv, then check the properties of the csv to copy the ABFS path.

Hope it works.
If this post helps please accept as solution to help others find it and a kudos would be appreciated.

Best Regards,
Vinay

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.