cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Pandas DataFrame error when using to_csv

afzi
New Contributor II

Hi Everyone, 

I would like to a Pandas Dataframe to /dbfs/FileStore/ using to_csv method.

Usually it would just write the Dataframe to the path described but It has been giving me "FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/FileStore/test.csv".

I have tried

df.to_csv("/dbfs/FileStore/test.csv", header= None, index= None)
 
df.to_csv("dbfs/FileStore/test.csv", header=None, index=None)
 
df.to_csv("dbfs:/FileStore/test.csv", header=None, index=None)
 
df.to_csv("/FileStore/test.csv", header=None, index=None)
 
df.to_csv("FileStore/test.csv", header=None, index=None)

But all give out the same error.

using dbutils i see that the folder are present.

dbutils.fs.ls("dbfs:/FileStore")
 
Out[32]: [FileInfo(path='dbfs:/FileStore/tables/', name='tables/', size=0, modificationTime=0)]

I am new here and i tried searching the problem for a long time but I can't find a solution. Please help.

1 REPLY 1

Avinash_94
New Contributor III

f = open("/dbfs/mnt/blob/myNames.txt", "r")

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.