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: 

[Errno 2] No such file or directory

otum
New Contributor II

I am reading a Json a file as in below location, using the below code, 

 

 

 

file_path = "/dbfs/mnt/platform-data/temp/ComplexJSON/sample.json"  # replace with the file path
f = open(file_path, "r")
print(f.read())

 

 

 

otum_0-1704950000614.png

 

otum_0-1704949958734.png

 

but it is failing for no such file or directory exists? 

Can someone please help me with the issue?

 

6 REPLIES 6

shan_chandra
Databricks Employee
Databricks Employee

Hi @otum , can you please try to cat the file first and validate if you are able to view the data first

%sh cat /dbfs/FileStore/babynames.csv

I was able to run the same commands as you and read the files. 

Thanks,

Shan

Screenshot 2024-01-11 at 10.35.03 AM.png

otum
New Contributor II

Hello @shan_chandra 

it isn't displaying with sh cat, but displaying with dbutils.fs.ls

Please find below is the image, 

otum_0-1705014575480.png

 

Debayan
Databricks Employee
Databricks Employee

Hi, Could you please try with dbfs:/ ? Also, could you please ls the absolute file path to see what's the content? 

otum
New Contributor II

Hello @Debayan 

Thanks for the reply, here is what I am getting when tried with dbfs:/

otum_1-1705014884302.png

 

shan_chandra
Databricks Employee
Databricks Employee

@otum  cat command should be given as below (not syntax verified).

%sh cat /dbfs/mnt/platform-data/temp/ComplexJSON/sample.json

 

Debayan
Databricks Employee
Databricks Employee

Hi, As Shan mentioned, could you please cat the file and see if it exists. 

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