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: 

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")

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