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:ย 

FileNotFoundError: [Errno 2] No such file or directory or IsADirectoryError: [Errno 21] Is a directory

AnaDel_Campo_Me
New Contributor

I have been trying to open a file on the dbfs using all different combinations:

if I use the following code:

with open("/dbfs/FileStore/df/Downloadedfile.csv", 'r', newline='') as f

I get IsADirectoryError: [Errno 21] Is a directory

with open("dbfs:/FileStore/df/Downloadedfile.csv", 'r', newline='') as f

FileNotFoundError: [Errno 2] No such file or directory

2 REPLIES 2

User16857282152
Contributor

@Ana Del Campo Mendizabal

There is a file explorer,

Use that to verify the file is where you expect it to be.

Here is a screenshot,

Basically

Click on Databricks on Left Navigation Panel,

And then Import and Explore Data in the center of the page

0693f000007OroFAAS

paulmark
New Contributor II

To get rid of this error you can try using Python file exists methods to check that at least python sees the file exists or not. In other words, you can make sure that the user has indeed typed a correct path for a real existing file. If the user does not pass the full path to the file, the path is interpreted relatively to the current working directory. The current working directory usually is the directory in which you started the program.

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