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

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!