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: 

Python open function is unable to detect the file in dbfs

billaspiel
New Contributor II

hi ,

Im a newbie learning spark using databricks , I did some investigation and searched if this questions was been asked earlier in community forum but unable to find anything so .

1. DBFS is unable to detect the file even though its present in it .

The issue happens only with below command

with open("dbfs:/FileStore/tables/data.txt") as f:

and not with

lines0 = sc.textFile("/FileStore/tables/data.txt"

Does this mean in databricks notebook we can't use python open function to open a file ?

1 ACCEPTED SOLUTION

Accepted Solutions

mathan_pillai
Databricks Employee
Databricks Employee

Hi @billaspiel

Can you please try by removing the colon ":" ? Here is a documentation on how to read/write the data

https://docs.databricks.com/user-guide/dbfs-databricks-file-system.html#access-dbfs-using-local-file...

If the issue still occurs, please share the complete statement and also the error message you are getting. Let us know how it goes.

Thanks

View solution in original post

3 REPLIES 3

mathan_pillai
Databricks Employee
Databricks Employee

Hi @billaspiel

Can you please try by removing the colon ":" ? Here is a documentation on how to read/write the data

https://docs.databricks.com/user-guide/dbfs-databricks-file-system.html#access-dbfs-using-local-file...

If the issue still occurs, please share the complete statement and also the error message you are getting. Let us know how it goes.

Thanks

Hi mathan,

Thanks for the information , in addition to removing colon':' added '/' as well before dbfs which resolved the issue .

working syntax

----------------------

with open("/dbfs/FileStore/tables/data.txt") as f:

Dflo
New Contributor II

I am having similar issues currently. I can read or access my storage account but when I attempted to read or access the container it told me path not found. I create the container and have full access as an owner.

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