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"}

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group