cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Why does spark.read.csv come back with an error: com.databricks.sql.io.FileReadException: Error while reading file dbfs:/mnt/cntnr/demo/circuits.csv ?

jch
New Contributor III

I need help understanding why I can't open a file.

In a databricks notebook, I use this code:

%fs
 
ls /mnt/cntnr/demo

I get back dbfs:/mnt/cntnr/demo/circuits.csv as one of the path values.

When I use this code, I get an error:

circuits_df = spark.read.csv("dbfs:/mnt/cntnr/demo/circuits.csv")

Any suggestions?

ANy suggestion

1 ACCEPTED SOLUTION

Accepted Solutions

Try this

circuits_df = spark.read.csv("/dbfs/mnt/cntnr/demo/circuits.csv")

View solution in original post

4 REPLIES 4

daniel_sahal
Esteemed Contributor

@jch​ 

Try spark.read.csv without dbfs:

You can learn more here:

https://docs.databricks.com/files/index.html

jch
New Contributor III

This didn't work either

circuits_df = spark.read.csv("/mnt/cntnr/demo/circuits.csv")

Try this

circuits_df = spark.read.csv("/dbfs/mnt/cntnr/demo/circuits.csv")

jch
New Contributor III

It turns out my spark config was wrong

    #Set Spark configuration

    configs = {"fs.azure.account.auth.type": "OAuth",

          "fs.azure.account.oauth.provider.type": "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",

          "fs.azure.account.oauth2.client.id": client_ID,

          "fs.azure.account.oauth2.client.secret": client_secret,

          "fs.azure.account.oauth2.client.endpoint": f"https://login.microsoftonline.com/{tenant_ID}/oauth2/token"}

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!