cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Honored Contributor III
Honored Contributor III

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
Esteemed Contributor III
Esteemed Contributor III

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
Honored Contributor III
Honored Contributor III

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

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

 

Debayan
Esteemed Contributor III
Esteemed Contributor III

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

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.